首页 文章

Angular 2 npm安装错误包

提问于
浏览
4

我正在使用Angular 2.Node版本是 v6.9.1 . Npm版本是: 4.0.3 . 当我运行 npm start 时,会显示以下错误:

ng2-fundamentals-demo@1.0.0 start /var/www/html/ng2-fundamentals
> tsc && concurrently "npm run tsc:w" "npm run server" 

app/app.module.ts(3,30): error TS2307: Cannot find module '@angular/router'.
app/events-list-resolver.service.ts(2,25): error TS2307: Cannot find module '@angular/router'.
app/events/create-event.component.ts(2,24): error TS2307: Cannot find module '@angular/router'.
app/events/event-details/event-details.component.ts(3,32): error TS2307: Cannot find module '@angular/router'.
app/events/event-details/event-route-activator.service.ts(1,61): error TS2307: Cannot find module '@angular/router'.
app/events/events-list.component.ts(4,32): error TS2307: Cannot find module '@angular/router'.
app/events/shared/event.service.ts(15,23): error TS2339: Property 'find' does not exist on type '({ id: number; name: string; date: string; time: string; price: number; imageUrl: string; session...'.
app/routes.ts(1,24): error TS2307: Cannot find module '@angular/router'.
node_modules/@angular/common/src/directives/ng_class.d.ts(48,34): error TS2304: Cannot find name 'Set'.
node_modules/@angular/common/src/pipes/async_pipe.d.ts(44,38): error TS2304: Cannot find name 'Promise'.
node_modules/@angular/compiler/src/aot/compiler.d.ts(32,38): error TS2304: Cannot find name 'Promise'.
node_modules/@angular/compiler/src/aot/compiler.d.ts(44,32): error TS2304: Cannot find name 'Map'.
node_modules/@angular/compiler/src/aot/compiler_host.d.ts(20,33): error TS2304: Cannot find name 'Promise'.
node_modules/@angular/compiler/src/compile_metadata.d.ts(342,20): error TS2304: Cannot find name 'Set'.
node_modules/@angular/compiler/src/compile_metadata.d.ts(344,28): error TS2304: Cannot find name 'Set'.
node_modules/@angular/compiler/src/compile_metadata.d.ts(346,15): error TS2304: Cannot find name 'Set'.
node_modules/@angular/compiler/src/compile_metadata.d.ts(348,23): error TS2304: Cannot find name 'Set'.
node_modules/@angular/compiler/src/compile_metadata.d.ts(350,17): error TS2304: Cannot find name 'Set'.
node_modules/@angular/compiler/src/compile_metadata.d.ts(352,25): error TS2304: Cannot find name 'Set'.
node_modules/@angular/compiler/src/directive_normalizer.d.ts(38,72): error TS2304: Cannot find name 'Promise'.
node_modules/@angular/compiler/src/directive_normalizer.d.ts(40,74): error TS2304: Cannot find name 'Promise'.
node_modules/@angular/compiler/src/i18n/extractor.d.ts(14,33): error TS2304: Cannot find name 'Promise'.
node_modules/@angular/compiler/src/i18n/extractor.d.ts(22,35): error TS2304: Cannot find name 'Promise'.
node_modules/@angular/compiler/src/jit/compiler.d.ts(44,49): error TS2304: Cannot find name 'Promise'.
node_modules/@angular/compiler/src/jit/compiler.d.ts(46,65): error TS2304: Cannot find name 'Promise'.
node_modules/@angular/compiler/src/metadata_resolver.d.ts(58,104): error TS2304: Cannot find name 'Promise'.
node_modules/@angular/compiler/src/output/output_ast.d.ts(433,63): error TS2304: Cannot find name 'Set'.
node_modules/@angular/compiler/src/resource_loader.d.ts(13,23): error TS2304: Cannot find name 'Promise'.
node_modules/@angular/compiler/src/util.d.ts(33,18): error TS2304: Cannot find name 'Promise'.
node_modules/@angular/compiler/src/util.d.ts(34,46): error TS2304: Cannot find name 'Promise'.
node_modules/@angular/core/src/application_init.d.ts(16,18): error TS2304: Cannot find name 'Promise'.
node_modules/@angular/core/src/application_ref.d.ts(116,76): error TS2304: Cannot find name 'Promise'.
node_modules/@angular/core/src/application_ref.d.ts(132,110): error TS2304: Cannot find name 'Promise'.
node_modules/@angular/core/src/application_ref.d.ts(158,67): error TS2304: Cannot find name 'Promise'.
node_modules/@angular/core/src/application_ref.d.ts(160,101): error TS2304: Cannot find name 'Promise'.
node_modules/@angular/core/src/change_detection/differs/default_keyvalue_differ.d.ts(24,15): error TS2304: Cannot find name 'Map'.
node_modules/@angular/core/src/change_detection/differs/default_keyvalue_differ.d.ts(28,16): error TS2304: Cannot find name 'Map'.
node_modules/@angular/core/src/di/reflective_provider.d.ts(87,123): error TS2304: Cannot find name 'Map'.
node_modules/@angular/core/src/di/reflective_provider.d.ts(87,165): error TS2304: Cannot find name 'Map'.
node_modules/@angular/core/src/facade/lang.d.ts(12,17): error TS2304: Cannot find name 'Map'.
node_modules/@angular/core/src/facade/lang.d.ts(13,17): error TS2304: Cannot find name 'Set'.
node_modules/@angular/core/src/linker/compiler.d.ts(53,49): error TS2304: Cannot find name 'Promise'.
node_modules/@angular/core/src/linker/compiler.d.ts(61,65): error TS2304: Cannot find name 'Promise'.
node_modules/@angular/core/src/linker/ng_module_factory_loader.d.ts(14,34): error TS2304: Cannot find name 'Promise'.
node_modules/@angular/core/src/linker/system_js_ng_module_factory_loader.d.ts(28,25): error TS2304: Cannot find name 'Promise'.
node_modules/@angular/core/src/util/lang.d.ts(12,53): error TS2304: Cannot find name 'Promise'.
node_modules/@angular/platform-browser-dynamic/src/resource_loader/resource_loader_impl.d.ts(10,23): error TS2304: Cannot find name 'Promise'.
node_modules/@angular/platform-browser/src/browser/browser_adapter.d.ts(79,33): error TS2304: Cannot find name 'Map'.
node_modules/@angular/platform-browser/src/dom/dom_adapter.d.ts(97,42): error TS2304: Cannot find name 'Map'.
node_modules/@angular/platform-browser/src/dom/dom_renderer.d.ts(22,37): error TS2304: Cannot find name 'Map'.
node_modules/@angular/platform-browser/src/dom/shared_styles_host.d.ts(11,30): error TS2304: Cannot find name 'Set'.
node_modules/@angular/platform-browser/src/dom/shared_styles_host.d.ts(22,30): error TS2304: Cannot find name 'Set'.
node_modules/@types/localforage/index.d.ts(25,25): error TS2304: Cannot find name 'Promise'.
node_modules/@types/localforage/index.d.ts(60,43): error TS2304: Cannot find name 'Promise'.
node_modules/@types/localforage/index.d.ts(62,46): error TS2304: Cannot find name 'Promise'.
node_modules/@types/localforage/index.d.ts(65,30): error TS2304: Cannot find name 'Promise'.
node_modules/@types/localforage/index.d.ts(68,40): error TS2304: Cannot find name 'Promise'.
node_modules/@types/localforage/index.d.ts(71,30): error TS2304: Cannot find name 'Promise'.
node_modules/@types/localforage/index.d.ts(74,14): error TS2304: Cannot find name 'Promise'.
node_modules/@types/localforage/index.d.ts(77,15): error TS2304: Cannot find name 'Promise'.
node_modules/@types/localforage/index.d.ts(80,28): error TS2304: Cannot find name 'Promise'.
node_modules/@types/localforage/index.d.ts(83,13): error TS2304: Cannot find name 'Promise'.
node_modules/@types/localforage/index.d.ts(86,83): error TS2304: Cannot find name 'Promise'.
node_modules/rxjs/Observable.d.ts(68,60): error TS2304: Cannot find name 'Promise'.
node_modules/rxjs/Observable.d.ts(68,70): error TS2304: Cannot find name 'Promise'.
node_modules/rxjs/observable/PromiseObservable.d.ts(40,31): error TS2304: Cannot find name 'Promise'.
node_modules/rxjs/observable/PromiseObservable.d.ts(41,26): error TS2304: Cannot find name 'Promise'.
node_modules/rxjs/operator/toPromise.d.ts(2,60): error TS2304: Cannot find name 'Promise'.
node_modules/rxjs/operator/toPromise.d.ts(3,79): error TS2304: Cannot find name 'Promise'.
node_modules/rxjs/operator/toPromise.d.ts(3,89): error TS2304: Cannot find name 'Promise'.

我尝试了很多这样的事情:npm uninstall -g angular-cli

npm cache clean rm -rf node_modules npm install --save

和其他问题,但仍然没有结果 .

我的package.json是:

{
  "name": "ng2-fundamentals-demo",
  "version": "1.0.0",
  "scripts": {
    "start": "tsc && concurrently \"npm run tsc:w\" \"npm run server\" ",
    "server": "node node_modules/ng2f-server/server.js",
    "tsc": "tsc",
    "tsc:w": "tsc -w"
  },
  "keywords": [],
  "author": "",
  "licenses": [
    {
      "type": "MIT",
      "url": "https://github.com/angular/angular.io/blob/master/LICENSE"
    }
  ],
  "dependencies": {
    "@angular/common": "2.4.8",
    "@angular/compiler": "2.4.8",
    "@angular/compiler-cli": "2.4.8",
    "@angular/core": "2.4.8",
    "@angular/forms": "2.4.8",
    "@angular/http": "2.4.8",
    "@angular/platform-browser": "2.4.8",
    "@angular/platform-browser-dynamic": "2.4.8",
    "@angular/platform-server": "2.4.8",
    "@ionic/storage": "2.0.0",
    "ionic-angular": "2.2.0",
    "ionic-native": "2.4.1",
    "ionicons": "3.0.0",
    "rxjs": "5.0.1",
    "sw-toolbox": "3.4.0",
    "zone.js": "0.7.2"
  },
  "devDependencies": {
    "@ionic/app-scripts": "1.1.4",
    "typescript": "2.0.9"
  },
  "repository": {}
}

如何修复包和Angular 2中的这些错误?

更新:现在我改变了package.json:

{
  "name": "ng2-fundamentals-demo",
  "version": "1.0.0",
  "scripts": {
    "start": "tsc && concurrently \"npm run tsc:w\" \"npm run server\" ",
    "server": "node node_modules/ng2f-server/server.js",
    "tsc": "tsc",
    "tsc:w": "tsc -w"
  },
  "keywords": [],
  "author": "",
  "licenses": [
    {
      "type": "MIT",
      "url": "https://github.com/angular/angular.io/blob/master/LICENSE"
    }
  ],
  "dependencies": {
    "@angular/common": "~2.4.0",
    "@angular/compiler": "~2.4.0",
    "@angular/core": "~2.4.0",
    "@angular/forms": "~2.4.0",
    "@angular/http": "~2.4.0",
    "@angular/platform-browser": "~2.4.0",
    "@angular/platform-browser-dynamic": "~2.4.0",
    "@angular/router": "^3.4.9",
    "angular-in-memory-web-api": "~0.2.4",
    "core-js": "^2.4.1",
    "rxjs": "5.0.1",
    "systemjs": "0.19.40",
    "zone.js": "^0.7.4"
  },
  "devDependencies": {
    "@types/core-js": "^0.9.37",
    "@types/jasmine": "2.5.36",
    "@types/node": "^6.0.46",
    "canonical-path": "0.0.2",
    "concurrently": "^3.2.0",
    "jasmine-core": "~2.4.1",
    "karma": "^1.3.0",
    "karma-chrome-launcher": "^2.0.0",
    "karma-cli": "^1.0.1",
    "karma-jasmine": "^1.0.2",
    "karma-jasmine-html-reporter": "^0.2.2",
    "lite-server": "^2.2.2",
    "lodash": "^4.16.4",
    "protractor": "~4.0.14",
    "rimraf": "^2.5.4",
    "tslint": "^3.15.1",
    "typescript": "~2.0.10"
  },
  "repository": {}
}

我跑了:rm -rf node_modules / npm install @ angular / cli -g npm install @ types / core-js --save-dev npm install @ angular / router -save

npm install npm run`

我得到了同样的错误:

> ng2-fundamentals-demo@1.0.0 start /var/www/html/ng2-fundamentals
> tsc && concurrently "npm run tsc:w" "npm run server" 

app/events/shared/event.service.ts(15,23): error TS2339: Property 'find' does not exist on type '({ id: number; name: string; date: string; time: string; price: number; imageUrl: string; session...'.
node_modules/@angular/common/src/pipes/async_pipe.d.ts(44,38): error TS2304: Cannot find name 'Promise'.
node_modules/@angular/compiler/src/aot/compiler.d.ts(32,38): error TS2304: Cannot find name 'Promise'.
node_modules/@angular/compiler/src/aot/compiler_host.d.ts(20,33): error TS2304: Cannot find name 'Promise'.
node_modules/@angular/compiler/src/directive_normalizer.d.ts(38,72): error TS2304: Cannot find name 'Promise'.
node_modules/@angular/compiler/src/directive_normalizer.d.ts(40,74): error TS2304: Cannot find name 'Promise'.
node_modules/@angular/compiler/src/i18n/extractor.d.ts(14,33): error TS2304: Cannot find name 'Promise'.
node_modules/@angular/compiler/src/i18n/extractor.d.ts(22,35): error TS2304: Cannot find name 'Promise'.
node_modules/@angular/compiler/src/jit/compiler.d.ts(44,49): error TS2304: Cannot find name 'Promise'.
node_modules/@angular/compiler/src/jit/compiler.d.ts(46,65): error TS2304: Cannot find name 'Promise'.
node_modules/@angular/compiler/src/metadata_resolver.d.ts(58,104): error TS2304: Cannot find name 'Promise'.
node_modules/@angular/compiler/src/resource_loader.d.ts(13,23): error TS2304: Cannot find name 'Promise'.
node_modules/@angular/compiler/src/util.d.ts(33,18): error TS2304: Cannot find name 'Promise'.
node_modules/@angular/compiler/src/util.d.ts(34,46): error TS2304: Cannot find name 'Promise'.
node_modules/@angular/core/src/application_init.d.ts(16,18): error TS2304: Cannot find name 'Promise'.
node_modules/@angular/core/src/application_ref.d.ts(116,76): error TS2304: Cannot find name 'Promise'.
node_modules/@angular/core/src/application_ref.d.ts(132,110): error TS2304: Cannot find name 'Promise'.
node_modules/@angular/core/src/application_ref.d.ts(158,67): error TS2304: Cannot find name 'Promise'.
node_modules/@angular/core/src/application_ref.d.ts(160,101): error TS2304: Cannot find name 'Promise'.
node_modules/@angular/core/src/facade/lang.d.ts(12,17): error TS2304: Cannot find name 'Map'.
node_modules/@angular/core/src/facade/lang.d.ts(13,17): error TS2304: Cannot find name 'Set'.
node_modules/@angular/core/src/linker/compiler.d.ts(53,49): error TS2304: Cannot find name 'Promise'.
node_modules/@angular/core/src/linker/compiler.d.ts(61,65): error TS2304: Cannot find name 'Promise'.
node_modules/@angular/core/src/linker/ng_module_factory_loader.d.ts(14,34): error TS2304: Cannot find name 'Promise'.
node_modules/@angular/core/src/linker/system_js_ng_module_factory_loader.d.ts(28,25): error TS2304: Cannot find name 'Promise'.
node_modules/@angular/core/src/util/lang.d.ts(12,53): error TS2304: Cannot find name 'Promise'.
node_modules/@angular/platform-browser-dynamic/src/resource_loader/resource_loader_impl.d.ts(10,23): error TS2304: Cannot find name 'Promise'.
node_modules/@angular/router/src/config.d.ts(307,85): error TS2304: Cannot find name 'Promise'.
node_modules/@angular/router/src/interfaces.d.ts(78,99): error TS2304: Cannot find name 'Promise'.
node_modules/@angular/router/src/interfaces.d.ts(157,109): error TS2304: Cannot find name 'Promise'.
node_modules/@angular/router/src/interfaces.d.ts(227,115): error TS2304: Cannot find name 'Promise'.
node_modules/@angular/router/src/interfaces.d.ts(297,89): error TS2304: Cannot find name 'Promise'.
node_modules/@angular/router/src/interfaces.d.ts(367,50): error TS2304: Cannot find name 'Promise'.
node_modules/@angular/router/src/router.d.ts(392,70): error TS2304: Cannot find name 'Promise'.
node_modules/@angular/router/src/router.d.ts(414,59): error TS2304: Cannot find name 'Promise'.
node_modules/@angular/router/src/utils/collection.d.ts(36,79): error TS2304: Cannot find name 'Promise'.
node_modules/@types/core-js/index.d.ts(47,36): error TS2304: Cannot find name 'Iterable'.
node_modules/@types/core-js/index.d.ts(350,48): error TS2304: Cannot find name 'PropertyKey'.
node_modules/@types/core-js/index.d.ts(351,52): error TS2304: Cannot find name 'PropertyKey'.
node_modules/@types/core-js/index.d.ts(352,34): error TS2304: Cannot find name 'PropertyKey'.
node_modules/@types/core-js/index.d.ts(353,34): error TS2304: Cannot find name 'PropertyKey'.
node_modules/@types/core-js/index.d.ts(354,34): error TS2304: Cannot find name 'PropertyKey'.
node_modules/@types/core-js/index.d.ts(355,61): error TS2304: Cannot find name 'PropertyKey'.
node_modules/@types/core-js/index.d.ts(356,60): error TS2304: Cannot find name 'PropertyKey'.
node_modules/@types/core-js/index.d.ts(357,65): error TS2304: Cannot find name 'PropertyKey'.
node_modules/@types/core-js/index.d.ts(357,97): error TS2304: Cannot find name 'PropertyKey'.
node_modules/@types/core-js/index.d.ts(358,60): error TS2304: Cannot find name 'PropertyKey'.
node_modules/@types/core-js/index.d.ts(359,58): error TS2304: Cannot find name 'PropertyKey'.
node_modules/@types/core-js/index.d.ts(360,59): error TS2304: Cannot find name 'PropertyKey'.
node_modules/@types/core-js/index.d.ts(361,58): error TS2304: Cannot find name 'PropertyKey'.
node_modules/@types/core-js/index.d.ts(362,61): error TS2304: Cannot find name 'PropertyKey'.
node_modules/@types/core-js/index.d.ts(362,117): error TS2304: Cannot find name 'PropertyKey'.
node_modules/@types/core-js/index.d.ts(363,42): error TS2304: Cannot find name 'PropertyKey'.
node_modules/@types/core-js/index.d.ts(365,81): error TS2304: Cannot find name 'PropertyKey'.
node_modules/@types/core-js/index.d.ts(366,78): error TS2304: Cannot find name 'PropertyKey'.
node_modules/@types/core-js/index.d.ts(367,76): error TS2304: Cannot find name 'PropertyKey'.
node_modules/@types/core-js/index.d.ts(368,73): error TS2304: Cannot find name 'PropertyKey'.
node_modules/@types/core-js/index.d.ts(431,6): error TS2304: Cannot find name 'Symbol'.
node_modules/@types/core-js/index.d.ts(456,39): error TS2304: Cannot find name 'Promise'.
node_modules/@types/core-js/index.d.ts(464,59): error TS2304: Cannot find name 'PropertyKey'.
node_modules/@types/core-js/index.d.ts(465,59): error TS2304: Cannot find name 'PropertyKey'.
node_modules/@types/core-js/index.d.ts(467,48): error TS2304: Cannot find name 'PropertyKey'.
node_modules/@types/core-js/index.d.ts(468,69): error TS2304: Cannot find name 'PropertyKey'.
node_modules/@types/core-js/index.d.ts(472,40): error TS2304: Cannot find name 'PropertyKey'.
node_modules/@types/core-js/index.d.ts(474,48): error TS2304: Cannot find name 'PropertyKey'.
node_modules/@types/core-js/index.d.ts(494,55): error TS2304: Cannot find name 'PropertyKey'.
node_modules/@types/core-js/index.d.ts(495,45): error TS2304: Cannot find name 'PropertyKey'.
node_modules/@types/core-js/index.d.ts(511,46): error TS2304: Cannot find name 'Iterable'.
node_modules/@types/core-js/index.d.ts(512,43): error TS2304: Cannot find name 'Iterable'.
node_modules/@types/core-js/index.d.ts(627,18): error TS2304: Cannot find name 'PromiseConstructor'.
node_modules/@types/core-js/index.d.ts(642,32): error TS2304: Cannot find name 'Iterable'.
node_modules/@types/core-js/index.d.ts(646,39): error TS2304: Cannot find name 'Iterable'.
node_modules/@types/core-js/index.d.ts(646,53): error TS2304: Cannot find name 'Iterator'.
node_modules/@types/core-js/index.d.ts(657,35): error TS2304: Cannot find name 'Promise'.
node_modules/@types/core-js/index.d.ts(1280,34): error TS2339: Property 'for' does not exist on type 'SymbolConstructor'.
node_modules/@types/core-js/index.d.ts(1284,41): error TS2339: Property 'hasInstance' does not exist on type 'SymbolConstructor'.
node_modules/@types/core-js/index.d.ts(1288,48): error TS2339: Property 'isConcatSpreadable' does not exist on type 'SymbolConstructor'.
node_modules/@types/core-js/index.d.ts(1292,38): error TS2339: Property 'iterator' does not exist on type 'SymbolConstructor'.
node_modules/@types/core-js/index.d.ts(1296,36): error TS2339: Property 'keyFor' does not exist on type 'SymbolConstructor'.
node_modules/@types/core-js/index.d.ts(1300,35): error TS2339: Property 'match' does not exist on type 'SymbolConstructor'.
node_modules/@types/core-js/index.d.ts(1304,37): error TS2339: Property 'replace' does not exist on type 'SymbolConstructor'.
node_modules/@types/core-js/index.d.ts(1308,36): error TS2339: Property 'search' does not exist on type 'SymbolConstructor'.
node_modules/@types/core-js/index.d.ts(1312,37): error TS2339: Property 'species' does not exist on type 'SymbolConstructor'.
node_modules/@types/core-js/index.d.ts(1316,35): error TS2339: Property 'split' does not exist on type 'SymbolConstructor'.
node_modules/@types/core-js/index.d.ts(1320,41): error TS2339: Property 'toPrimitive' does not exist on type 'SymbolConstructor'.
node_modules/@types/core-js/index.d.ts(1324,41): error TS2339: Property 'toStringTag' does not exist on type 'SymbolConstructor'.
node_modules/@types/core-js/index.d.ts(1328,41): error TS2339: Property 'unscopables' does not exist on type 'SymbolConstructor'.
node_modules/@types/core-js/index.d.ts(2059,34): error TS2339: Property 'for' does not exist on type 'SymbolConstructor'.
node_modules/@types/core-js/index.d.ts(2063,41): error TS2339: Property 'hasInstance' does not exist on type 'SymbolConstructor'.
node_modules/@types/core-js/index.d.ts(2067,48): error TS2339: Property 'isConcatSpreadable' does not exist on type 'SymbolConstructor'.
node_modules/@types/core-js/index.d.ts(2071,38): error TS2339: Property 'iterator' does not exist on type 'SymbolConstructor'.
node_modules/@types/core-js/index.d.ts(2075,36): error TS2339: Property 'keyFor' does not exist on type 'SymbolConstructor'.
node_modules/@types/core-js/index.d.ts(2079,35): error TS2339: Property 'match' does not exist on type 'SymbolConstructor'.
node_modules/@types/core-js/index.d.ts(2083,37): error TS2339: Property 'replace' does not exist on type 'SymbolConstructor'.
node_modules/@types/core-js/index.d.ts(2087,36): error TS2339: Property 'search' does not exist on type 'SymbolConstructor'.
node_modules/@types/core-js/index.d.ts(2091,37): error TS2339: Property 'species' does not exist on type 'SymbolConstructor'.
node_modules/@types/core-js/index.d.ts(2095,35): error TS2339: Property 'split' does not exist on type 'SymbolConstructor'.
node_modules/@types/core-js/index.d.ts(2099,41): error TS2339: Property 'toPrimitive' does not exist on type 'SymbolConstructor'.
node_modules/@types/core-js/index.d.ts(2103,41): error TS2339: Property 'toStringTag' does not exist on type 'SymbolConstructor'.
node_modules/@types/core-js/index.d.ts(2107,41): error TS2339: Property 'unscopables' does not exist on type 'SymbolConstructor'.
node_modules/rxjs/Observable.d.ts(68,60): error TS2304: Cannot find name 'Promise'.
node_modules/rxjs/Observable.d.ts(68,70): error TS2304: Cannot find name 'Promise'.
node_modules/rxjs/observable/PromiseObservable.d.ts(40,31): error TS2304: Cannot find name 'Promise'.
node_modules/rxjs/observable/PromiseObservable.d.ts(41,26): error TS2304: Cannot find name 'Promise'.
node_modules/rxjs/operator/toPromise.d.ts(2,60): error TS2304: Cannot find name 'Promise'.
node_modules/rxjs/operator/toPromise.d.ts(3,79): error TS2304: Cannot find name 'Promise'.
node_modules/rxjs/operator/toPromise.d.ts(3,89): error TS2304: Cannot find name 'Promise'.

npm ERR! Linux 3.19.0-32-generic
npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "start"
npm ERR! node v6.9.1
npm ERR! npm  v4.0.3
npm ERR! code ELIFECYCLE
npm ERR! ng2-fundamentals-demo@1.0.0 start: `tsc && concurrently "npm run tsc:w" "npm run server" `
npm ERR! Exit status 2
npm ERR! 
npm ERR! Failed at the ng2-fundamentals-demo@1.0.0 start script 'tsc && concurrently "npm run tsc:w" "npm run server" '.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the ng2-fundamentals-demo package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     tsc && concurrently "npm run tsc:w" "npm run server" 
npm ERR! You can get information on how to open an issue for this project with:
npm ERR!     npm bugs ng2-fundamentals-demo
npm ERR! Or if that isn't available, you can get their info via:
npm ERR!     npm owner ls ng2-fundamentals-demo
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR!     /var/www/html/ng2-fundamentals/npm-debug.log

4 回答

  • 1

    使用CLI重新安装所有内容对我有用我最近遇到了类似的问题,你可以试试

    • nvm安装节点

    • nvm使用7.4.0(无论您使用的是什么版本)

    • nvm别名默认为v7.4.0

    • npm install -g npm

    • npm install -g @ angular / cli ng new myapp

    • ng服务

  • 1

    我有同样的问题 . 几个小时后,我意识到@ types / core-js会产生问题 .

    将package.json中的更改为版本:

    "@types/core-js": "0.9.35"
    

    当然,你必须这样做:

    npm安装

    在继续之前删除node_modules会很棒 .

  • 1

    你的package.json没有角度路由器 . 将它放在package.json中手动 "@angular/router": "~3.4.0", 并在同一文件夹中键入命令 npm install . 或者做 npm install @angular/router --save

    以下是一个典型的package.json应该是一个角度项目的样子:

    {
      "name": "angular-quickstart",
      "version": "1.0.0",
      "description": "QuickStart package.json from the documentation, supplemented with testing support",
      "scripts": {
        "build": "tsc -p src/",
        "build:watch": "tsc -p src/ -w",
        "build:e2e": "tsc -p e2e/",
        "serve": "lite-server -c=bs-config.json",
        "serve:e2e": "lite-server -c=bs-config.e2e.json",
        "prestart": "npm run build",
        "start": "concurrently \"npm run build:watch\" \"npm run serve\"",
        "pree2e": "npm run build:e2e",
        "e2e": "concurrently \"npm run serve:e2e\" \"npm run protractor\" --kill-others --success first",
        "preprotractor": "webdriver-manager update",
        "protractor": "protractor protractor.config.js",
        "pretest": "npm run build",
        "test": "concurrently \"npm run build:watch\" \"karma start karma.conf.js\"",
        "pretest:once": "npm run build",
        "test:once": "karma start karma.conf.js --single-run",
        "lint": "tslint ./src/**/*.ts -t verbose"
      },
      "keywords": [],
      "author": "",
      "license": "MIT",
      "dependencies": {
        "@angular/common": "~2.4.0",
        "@angular/compiler": "~2.4.0",
        "@angular/core": "~2.4.0",
        "@angular/forms": "~2.4.0",
        "@angular/http": "~2.4.0",
        "@angular/platform-browser": "~2.4.0",
        "@angular/platform-browser-dynamic": "~2.4.0",
        "@angular/router": "~3.4.0",
    
        "angular-in-memory-web-api": "~0.2.4",
        "systemjs": "0.19.40",
        "core-js": "^2.4.1",
        "rxjs": "5.0.1",
        "zone.js": "^0.7.4"
      },
      "devDependencies": {
        "concurrently": "^3.2.0",
        "lite-server": "^2.2.2",
        "typescript": "~2.0.10",
    
        "canonical-path": "0.0.2",
        "tslint": "^3.15.1",
        "lodash": "^4.16.4",
        "jasmine-core": "~2.4.1",
        "karma": "^1.3.0",
        "karma-chrome-launcher": "^2.0.0",
        "karma-cli": "^1.0.1",
        "karma-jasmine": "^1.0.2",
        "karma-jasmine-html-reporter": "^0.2.2",
        "protractor": "~4.0.14",
        "rimraf": "^2.5.4",
    
        "@types/node": "^6.0.46",
        "@types/jasmine": "2.5.36"
      },
      "repository": {}
    }
    

    添加其他包/依赖关系,如ionic也符合您的需求 .

    https://docs.npmjs.com/cli/install

  • 3

    你的项目没有角度路由器和@ types / core-js,尝试手动安装它们:

    npm install @angular/router -save
    
    npm install  @types/core-js --save-dev
    

    或者只使用@ angular / cli它会为角度应用提供你想要的任何东西:

    npm install @angular/cli -g
    
    ng new myapp
    
    ng serve
    

相关问题