我正在努力学习Angular并买了一本书。示例代码不会运行。我让Angular快速启动项目运行,但不是这样。也许有人可以提供帮助。
这是运行npm start
时收到的错误消息:
npm ERR! Windows_NT 10.0.14393
npm ERR! argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "start"
npm ERR! node v6.11.5
npm ERR! npm v3.10.10
npm ERR! code ELIFECYCLE
npm ERR! blog-app@1.0.0 start: `tsc && npm run copy:html && concurrently "npm run tsc:w" "npm run html:watch" "live-server" `
npm ERR! Exit status 2
npm ERR!
npm ERR! Failed at the blog-app@1.0.0 start script 'tsc && npm run copy:html && concurrently "npm run tsc:w" "npm run html:watch" "live-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 blog-app package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! tsc && npm run copy:html && concurrently "npm run tsc:w" "npm run html:watch" "live-server"
npm ERR! You can get information on how to open an issue for this project with:
npm ERR! npm bugs blog-app
npm ERR! Or if that isn't available, you can get their info via:
npm ERR! npm owner ls blog-app
npm ERR! There is likely additional logging output above.
npm ERR! Please include the following file with any support request:
npm ERR! E:\angular\kickstart\blog-start\npm-debug.log
这是我的package.json:
{
"name": "blog-app",
"version": "1.0.0",
"description": "Blog Applikation",
"watch": {
"copy:html": "./app/**/*.html"
},
"scripts": {
"start": "tsc && npm run copy:html && concurrently \"npm run tsc:w\" \"npm run html:watch\" \"live-server\" ",
"tsc": "./node_modules/.bin/tsc",
"tsc:w": "./node_modules/.bin/tsc --watch",
"copy:html": "copyfiles -u 1 ./app/**/*.html dist",
"html:watch": "onchange \"./app/**/*.html\" -v -- npm run copy:html"
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"@angular/common": ">=4.0.0-beta <5.0.0",
"@angular/compiler": ">=4.0.0-beta <5.0.0",
"@angular/core": ">=4.0.0-beta <5.0.0",
"@angular/forms": ">=4.0.0-beta <5.0.0",
"@angular/http": ">=4.0.0-beta <5.0.0",
"@angular/platform-browser": ">=4.0.0-beta <5.0.0",
"@angular/platform-browser-dynamic": ">=4.0.0-beta <5.0.0",
"systemjs": "0.19.27",
"core-js": "^2.4.1",
"reflect-metadata": "^0.1.3",
"rxjs": "5.1.0",
"zone.js": "^0.8.4",
"bootstrap": "^3.3.6"
},
"devDependencies": {
"canonical-path": "0.0.2",
"concurrently": "^2.2.0",
"copyfiles": "^1.0.0",
"http-server": "^0.9.0",
"live-server": "^1.1.0",
"lodash": "^4.11.1",
"npm-watch": "^0.1.6",
"onchange": "^3.0.2",
"rimraf": "^2.5.2",
"tslint": "^3.7.4",
"typescript": "^2.0.2",
"typings": "^1.0.4"
},
"repository": {}
}
我尝试了Stackoverflow帖子的一些解决方案(比如更改启动脚本,但没有用。)
编辑: 尝试更新NPM,没有帮助:
PS E:\angular\kickstart\blog-start> npm start
> blog-app@1.0.0 start E:\angular\kickstart\blog-start
> tsc && npm run copy:html && concurrently "npm run tsc:w" "npm run html:watch" "live-server"
node_modules/rxjs/Subject.d.ts(16,22): error TS2415: Class 'Subject<T>' incorrectly extends base class 'Observable<T>'.
Types of property 'lift' are incompatible.
Type '<R>(operator: Operator<T, R>) => Observable<T>' is not assignable to type '<R>(operator: Operator<T, R>) => Observable<R>'.
Type 'Observable<T>' is not assignable to type 'Observable<R>'.
Type 'T' is not assignable to type 'R'.
npm ERR! code ELIFECYCLE
npm ERR! errno 2
npm ERR! blog-app@1.0.0 start: `tsc && npm run copy:html && concurrently "npm run tsc:w" "npm run html:watch" "live-server" `
npm ERR! Exit status 2
npm ERR!
npm ERR! Failed at the blog-app@1.0.0 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\XYZ\AppData\Roaming\npm-cache\_logs\2017-10-26T10_14_42_254Z-debug.log
日志文件:
0 info it worked if it ends with ok
1 verbose cli [ 'C:\\Program Files\\nodejs\\node.exe',
1 verbose cli 'C:\\Users\\XYZ\\AppData\\Roaming\\npm\\node_modules\\npm\\bin\\npm-cli.js',
1 verbose cli 'start' ]
2 info using npm@5.5.1
3 info using node@v6.11.5
4 verbose run-script [ 'prestart', 'start', 'poststart' ]
5 info lifecycle blog-app@1.0.0~prestart: blog-app@1.0.0
6 info lifecycle blog-app@1.0.0~start: blog-app@1.0.0
7 verbose lifecycle blog-app@1.0.0~start: unsafe-perm in lifecycle true
8 verbose lifecycle blog-app@1.0.0~start: PATH: C:\Users\XYZ\AppData\Roaming\npm\node_modules\npm\bin\node-gyp-bin;E:\angular\kickstart\blog-start\node_modules\.bin;C:\ProgramData\Oracle\Java\javapath;C:\Program Files (x86)\Intel\iCLS Client\;C:\Program Files\Intel\iCLS Client\;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files (x86)\Microsoft SQL Server\110\Tools\Binn\ManagementStudio\;C:\Program Files (x86)\Microsoft SQL Server\110\Tools\Binn\;C:\Program Files\Microsoft SQL Server\110\Tools\Binn\;C:\Program Files (x86)\Microsoft SQL Server\110\DTS\Binn\;C:\Windows\system32\config\systemprofile\.dnx\bin;C:\Program Files\Microsoft DNX\Dnvm\;C:\Program Files (x86)\Windows Kits\8.1\Windows Performance Toolkit\;C:\Program Files\Microsoft SQL Server\120\Tools\Binn\;C:\Program Files\Microsoft SQL Server\130\Tools\Binn\;C:\Program Files (x86)\Microsoft Emulator Manager\1.0\;C:\Program Files (x86)\Microsoft SQL Server\100\Tools\Binn\;C:\Program Files\Microsoft SQL Server\100\Tools\Binn\;C:\Program Files\Microsoft SQL Server\100\DTS\Binn\;C:\Program Files\Microsoft\Web Platform Installer\;C:\Program Files (x86)\Microsoft ASP.NET\ASP.NET Web Pages\v1.0\;C:\Program Files (x86)\Microsoft Team Foundation Server 2015 Power Tools\;C:\MinGW\bin;C:\Program Files\nodejs\;C:\Users\XYZ\AppData\Local\Programs\Python\Python36-32\Scripts\;C:\Users\XYZ\AppData\Local\Programs\Python\Python36-32\;C:\Users\XYZ\AppData\Local\Programs\Python\Launcher\;C:\Users\XYZ\AppData\Local\Microsoft\WindowsApps;;C:\Program Files (x86)\Microsoft VS Code\bin;C:\Program Files (x86)\CMake\bin;C:\Users\XYZ\AppData\Roaming\npm
9 verbose lifecycle blog-app@1.0.0~start: CWD: E:\angular\kickstart\blog-start
10 silly lifecycle blog-app@1.0.0~start: Args: [ '/d /s /c',
10 silly lifecycle 'tsc && npm run copy:html && concurrently "npm run tsc:w" "npm run html:watch" "live-server" ' ]
11 silly lifecycle blog-app@1.0.0~start: Returned: code: 2 signal: null
12 info lifecycle blog-app@1.0.0~start: Failed to exec start script
13 verbose stack Error: blog-app@1.0.0 start: `tsc && npm run copy:html && concurrently "npm run tsc:w" "npm run html:watch" "live-server" `
13 verbose stack Exit status 2
13 verbose stack at EventEmitter.<anonymous> (C:\Users\XYZ\AppData\Roaming\npm\node_modules\npm\node_modules\npm-lifecycle\index.js:280:16)
13 verbose stack at emitTwo (events.js:106:13)
13 verbose stack at EventEmitter.emit (events.js:191:7)
13 verbose stack at ChildProcess.<anonymous> (C:\Users\XYZ\AppData\Roaming\npm\node_modules\npm\node_modules\npm-lifecycle\lib\spawn.js:55:14)
13 verbose stack at emitTwo (events.js:106:13)
13 verbose stack at ChildProcess.emit (events.js:191:7)
13 verbose stack at maybeClose (internal/child_process.js:920:16)
13 verbose stack at Process.ChildProcess._handle.onexit (internal/child_process.js:230:5)
14 verbose pkgid blog-app@1.0.0
15 verbose cwd E:\angular\kickstart\blog-start
16 verbose Windows_NT 10.0.14393
17 verbose argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Users\\XYZ\\AppData\\Roaming\\npm\\node_modules\\npm\\bin\\npm-cli.js" "start"
18 verbose node v6.11.5
19 verbose npm v5.5.1
20 error code ELIFECYCLE
21 error errno 2
22 error blog-app@1.0.0 start: `tsc && npm run copy:html && concurrently "npm run tsc:w" "npm run html:watch" "live-server" `
22 error Exit status 2
23 error Failed at the blog-app@1.0.0 start script.
23 error This is probably not a problem with npm. There is likely additional logging output above.
24 verbose exit [ 2, true ]
答案 0 :(得分:1)
您必须安装较新版本的node.js和npm:
Node JS
NPM:npm install npm@latest -g
答案 1 :(得分:0)
看起来它与Angular CLI有关( npm ERR!argv&#34; C:\ Program Files \ nodejs \ node.exe&#34;&#34; C:\ Program Files \ nodejs \ node_modules \ npm \ bin \ npm-cli.js&#34;&#34; start&#34; ),这是我在package.json文件中看不到的
我建议您使用Angular CLI创建一个新的清洁项目 创建一些新文件夹 安装Angular CLI - &gt; npm install @ angular / cli 安装角度项目 - &gt;新的你的项目名称
您可以随时尝试使用上面的命令更新到NodeJS的最新版本或仅在当前项目中安装Angular CLI