Angular 2 npm 安装错误包
Posted
技术标签:
【中文标题】Angular 2 npm 安装错误包【英文标题】:Angular 2 npm install error packages 【发布时间】:2017-08-01 23:31:44 【问题描述】:我正在使用 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 卸载 -g angular-cli
npm 缓存清理 rm -rf 节点模块 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 节点模块/ npm install @angular/cli -g npm install @types/core-js --save-dev npm install @angular/router -save
npm 安装 npm 运行`
我也遇到了同样的错误:
> 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
【问题讨论】:
你在使用 ionic 【参考方案1】:我遇到了同样的问题。几个小时后,我意识到@types/core-js 造成了问题。
在 package.json 中将其更改为版本:
"@types/core-js": "0.9.35"
当然,你必须这样做:
npm 安装
在继续之前完全删除 node_modules 会很棒。
【讨论】:
【参考方案2】:您的 package.json 没有角路由器。手动将其放入您的 package.json "@angular/router": "~3.4.0",
并在同一文件夹中键入命令 npm install
。或者npm install @angular/router --save
以下是 Angular 项目的典型 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
【讨论】:
我更新了我的问题。我删除了节点包,更改了 package.json 文件,再次运行这些命令和这些错误。 请检查您的活动服务。您指定的类型上没有 find 方法。这是升级节点本身的好时机。可能是您正在运行一个非常旧的节点分布。您可以尝试一下并显示应用查找的代码以及如何应用吗? 它工作正常,这是一项自定义服务。但是在我更新了 angular-cli 和 node 之后,它就坏了。不管怎样,我会尝试将我的应用程序结构更改为与 Angular 文档相同。【参考方案3】:您的项目没有 angular router 和 @types/core-js,请尝试手动安装:
npm install @angular/router -save
npm install @types/core-js --save-dev
或者只是使用@angular/cli,它会为 Angular 应用程序提供任何你想要的东西:
npm install @angular/cli -g
ng new myapp
ng serve
【讨论】:
【参考方案4】:使用 CLI 重新安装所有内容对我有用 我最近遇到了类似的问题,您可以尝试
nvm 安装节点nvm 使用 7.4.0(无论您使用什么版本)
nvm 别名默认 v7.4.0
npm install -g npm
npm install -g @angular/cli ng new myapp
ng 服务
【讨论】:
是的。我已经尝试过了,它以这种方式适用于新创建的项目。但我正在 Pluralsight 中观看视频教程 - app.pluralsight.com/…。它使用在 systemjsconfig 文件中声明的npm start
命令,我只是想让它再次工作。
这里是教程的练习文件:github.com/jmcooper/angular2-fundamentals-files。它使用节点版本 6.3。
@mistery_girl 你必须知道 @angular/cli 和 wepback 是要走的路,即使是 tuto 也在使用 systemjs。尝试使用 @angular/cli 和 webpack
嗯,我的 package.json 和教程一样,但是现在出现了这些错误。我应该如何解决这个问题?
@mistery_girl 我也在关注如何启动 angular cli 和启动项目的方式以旧格式给出,在那里他们使用 system.js,这不是 angular 2 的推荐方式我建议您仅参考复数形式并使用新方法来解决问题,因为 angular2 直到最近都经历了很多变化,并且仍然有很多变化。以上是关于Angular 2 npm 安装错误包的主要内容,如果未能解决你的问题,请参考以下文章
Angular 6:npm 错误!安装 Angular cdk 时从不调用 cb()
Windows 10 中的 npm 安装错误( npm install -g angular-cli )