我是Angular 2的新手,我在启动基本应用时遇到了一些错误。我只是创建一个新组件并将其加速。没什么。
这是我的package.json:
{
"name": "angular2-quickstart",
"version": "1.0.0",
"scripts": {
"start": "concurrently \"npm run tsc:w\" \"npm run lite\" ",
"tsc": "tsc",
"tsc:w": "tsc -w",
"lite": "lite-server",
"typings": "typings",
"postinstall": "typings install"
},
"license": "ISC",
"dependencies": {
"@ngrx/store": "^1.3.3",
"angular2": "2.0.0-beta.9",
"es6-promise": "^3.0.2",
"es6-shim": "^0.33.3",
"reflect-metadata": "0.1.2",
"rxjs": "5.0.0-beta.2",
"systemjs": "0.19.24",
"zone.js": "0.5.15"
},
"devDependencies": {
"concurrently": "^2.0.0",
"lite-server": "^2.1.0",
"typescript": "^1.8.7",
"typings": "^0.7.5"
}
}
我有最新版本的node& NPM。我还在全局安装了devDependencies。
当我尝试运行tsc时的错误日志:
0 info it worked if it ends with ok
1 verbose cli [ 'C:\\Program Files\\nodejs\\node.exe',
1 verbose cli 'C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js',
1 verbose cli 'run',
1 verbose cli 'tsc' ]
2 info using npm@3.7.3
3 info using node@v5.8.0
4 verbose run-script [ 'pretsc', 'tsc', 'posttsc' ]
5 info lifecycle angular2-quickstart@1.0.0~pretsc: angular2-quickstart@1.0.0
6 silly lifecycle angular2-quickstart@1.0.0~pretsc: no script for pretsc, continuing
7 info lifecycle angular2-quickstart@1.0.0~tsc: angular2-quickstart@1.0.0
8 verbose lifecycle angular2-quickstart@1.0.0~tsc: unsafe-perm in lifecycle true
9 verbose lifecycle angular2-quickstart@1.0.0~tsc: PATH: C:\Program Files\nodejs\node_modules\npm\bin\node-gyp-bin;D:\__\mdev\node_modules\.bin;C:\Program Files\nodejs;C:\cmder\bin;C:\Program Files\Git\bin;C:\Program Files\Git\usr\bin;C:\Program Files\Git\share\vim\vim74;C:\cmder\vendor\conemu-maximus5;C:\cmder\vendor\conemu-maximus5\ConEmu;C:\Ruby22-x64\bin;C:\Program Files (x86)\OpenSSH\bin;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 (x86)\Microsoft SQL Server\100\DTS\Binn\;C:\Program Files (x86)\Microsoft SQL Server\100\Tools\Binn\VSShell\Common7\IDE\;C:\Program Files (x86)\Microsoft SDKs\TypeScript\1.0\;C:\Program Files (x86)\Windows Kits\8.1\Windows Performance Toolkit\;C:\Program Files\Microsoft SQL Server\120\Tools\Binn\;C:\Program Files (x86)\Skype\Phone\;C:\Program Files\nodejs\;C:\Program Files (x86)\IDM Computer Solutions\UltraEdit\;C:\Users\cflodrops\Downloads\windows-7.0.0\windrush;C:\Program Files (x86)\Git\bin;C:\Program Files (x86)\Git\cmd;C:\Program Files\Oracle\VirtualBox;C:\Program Files\Git\bin;C:\MinGW\bin;C:\wamp\bin\mysql\mysql5.6.17\bin;C:\Users\cflodrops\AppData\Local\atom\bin;C:\ProgramData\Drush\;C:\Program Files (x86)\Drush\GnuWin32\bin;C:\Program Files (x86)\Drush\Php;C:\Program Files (x86)\Drush\cwRsync\bin;C:\Program Files (x86)\Microsoft VS Code\bin;\\sdossier.groupe.zzroot.com\dossiers$\cflodrops\AppData\npm;C:\cmder
10 verbose lifecycle angular2-quickstart@1.0.0~tsc: CWD: D:\__\mdev
11 silly lifecycle angular2-quickstart@1.0.0~tsc: Args: [ '/d /s /c', 'tsc' ]
12 silly lifecycle angular2-quickstart@1.0.0~tsc: Returned: code: 2 signal: null
13 info lifecycle angular2-quickstart@1.0.0~tsc: Failed to exec tsc script
14 verbose stack Error: angular2-quickstart@1.0.0 tsc: `tsc`
14 verbose stack Exit status 2
14 verbose stack at EventEmitter.<anonymous> (C:\Program Files\nodejs\node_modules\npm\lib\utils\lifecycle.js:239:16)
14 verbose stack at emitTwo (events.js:100:13)
14 verbose stack at EventEmitter.emit (events.js:185:7)
14 verbose stack at ChildProcess.<anonymous> (C:\Program Files\nodejs\node_modules\npm\lib\utils\spawn.js:24:14)
14 verbose stack at emitTwo (events.js:100:13)
14 verbose stack at ChildProcess.emit (events.js:185:7)
14 verbose stack at maybeClose (internal/child_process.js:850:16)
14 verbose stack at Process.ChildProcess._handle.onexit (internal/child_process.js:215:5)
15 verbose pkgid angular2-quickstart@1.0.0
16 verbose cwd D:\__\mdev
17 error Windows_NT 6.1.7601
18 error argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "run" "tsc"
19 error node v5.8.0
20 error npm v3.7.3
21 error code ELIFECYCLE
22 error angular2-quickstart@1.0.0 tsc: `tsc`
22 error Exit status 2
23 error Failed at the angular2-quickstart@1.0.0 tsc script 'tsc'.
23 error Make sure you have the latest version of node.js and npm installed.
23 error If you do, this is most likely a problem with the angular2-quickstart package,
23 error not with npm itself.
23 error Tell the author that this fails on your system:
23 error tsc
23 error You can get information on how to open an issue for this project with:
23 error npm bugs angular2-quickstart
23 error Or if that isn't available, you can get their info via:
23 error npm owner ls angular2-quickstart
23 error There is likely additional logging output above.
24 verbose exit [ 1, true ]
当我执行npm start:
时0 info it worked if it ends with ok
1 verbose cli [ 'C:\\Program Files\\nodejs\\node.exe',
1 verbose cli 'C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js',
1 verbose cli 'run',
1 verbose cli 'lite' ]
2 info using npm@3.7.3
3 info using node@v5.8.0
4 verbose run-script [ 'prelite', 'lite', 'postlite' ]
5 info lifecycle angular2-quickstart@1.0.0~prelite: angular2-quickstart@1.0.0
6 silly lifecycle angular2-quickstart@1.0.0~prelite: no script for prelite, continuing
7 info lifecycle angular2-quickstart@1.0.0~lite: angular2-quickstart@1.0.0
8 verbose lifecycle angular2-quickstart@1.0.0~lite: unsafe-perm in lifecycle true
9 verbose lifecycle angular2-quickstart@1.0.0~lite: PATH: C:\Program Files\nodejs\node_modules\npm\bin\node-gyp-bin;D:\__\mdev\node_modules\.bin;C:\Program Files\nodejs;C:\Program Files\nodejs\node_modules\npm\bin\node-gyp-bin;D:\__\mdev\node_modules\.bin;C:\Program Files\nodejs;C:\cmder\bin;C:\Program Files\Git\bin;C:\Program Files\Git\usr\bin;C:\Program Files\Git\share\vim\vim74;C:\cmder\vendor\conemu-maximus5;C:\cmder\vendor\conemu-maximus5\ConEmu;C:\Ruby22-x64\bin;C:\Program Files (x86)\OpenSSH\bin;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 (x86)\Microsoft SQL Server\100\DTS\Binn\;C:\Program Files (x86)\Microsoft SQL Server\100\Tools\Binn\VSShell\Common7\IDE\;C:\Program Files (x86)\Microsoft SDKs\TypeScript\1.0\;C:\Program Files (x86)\Windows Kits\8.1\Windows Performance Toolkit\;C:\Program Files\Microsoft SQL Server\120\Tools\Binn\;C:\Program Files (x86)\Skype\Phone\;C:\Program Files\nodejs\;C:\Program Files (x86)\IDM Computer Solutions\UltraEdit\;C:\Users\cflodrops\Downloads\windows-7.0.0\windrush;C:\Program Files (x86)\Git\bin;C:\Program Files (x86)\Git\cmd;C:\Program Files\Oracle\VirtualBox;C:\Program Files\Git\bin;C:\MinGW\bin;C:\wamp\bin\mysql\mysql5.6.17\bin;C:\Users\cflodrops\AppData\Local\atom\bin;C:\ProgramData\Drush\;C:\Program Files (x86)\Drush\GnuWin32\bin;C:\Program Files (x86)\Drush\Php;C:\Program Files (x86)\Drush\cwRsync\bin;C:\Program Files (x86)\Microsoft VS Code\bin;\\sdossier.groupe.zzroot.com\dossiers$\cflodrops\AppData\npm;C:\cmder
10 verbose lifecycle angular2-quickstart@1.0.0~lite: CWD: D:\__\mdev
11 silly lifecycle angular2-quickstart@1.0.0~lite: Args: [ '/d /s /c', 'lite-server' ]
12 silly lifecycle angular2-quickstart@1.0.0~lite: Returned: code: 1 signal: null
13 info lifecycle angular2-quickstart@1.0.0~lite: Failed to exec lite script
14 verbose stack Error: angular2-quickstart@1.0.0 lite: `lite-server`
14 verbose stack Exit status 1
14 verbose stack at EventEmitter.<anonymous> (C:\Program Files\nodejs\node_modules\npm\lib\utils\lifecycle.js:239:16)
14 verbose stack at emitTwo (events.js:100:13)
14 verbose stack at EventEmitter.emit (events.js:185:7)
14 verbose stack at ChildProcess.<anonymous> (C:\Program Files\nodejs\node_modules\npm\lib\utils\spawn.js:24:14)
14 verbose stack at emitTwo (events.js:100:13)
14 verbose stack at ChildProcess.emit (events.js:185:7)
14 verbose stack at maybeClose (internal/child_process.js:850:16)
14 verbose stack at Process.ChildProcess._handle.onexit (internal/child_process.js:215:5)
15 verbose pkgid angular2-quickstart@1.0.0
16 verbose cwd D:\__\mdev
17 error Windows_NT 6.1.7601
18 error argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "run" "lite"
19 error node v5.8.0
20 error npm v3.7.3
21 error code ELIFECYCLE
22 error angular2-quickstart@1.0.0 lite: `lite-server`
22 error Exit status 1
23 error Failed at the angular2-quickstart@1.0.0 lite script 'lite-server'.
23 error Make sure you have the latest version of node.js and npm installed.
23 error If you do, this is most likely a problem with the angular2-quickstart package,
23 error not with npm itself.
23 error Tell the author that this fails on your system:
23 error lite-server
23 error You can get information on how to open an issue for this project with:
23 error npm bugs angular2-quickstart
23 error Or if that isn't available, you can get their info via:
23 error npm owner ls angular2-quickstart
23 error There is likely additional logging output above.
24 verbose exit [ 1, true ]
答案 0 :(得分:0)
好的,问题来自lite-server。我决定安装http-server并改变我的package.json:
{
"name": "angular2-quickstart",
"version": "1.0.0",
"scripts": {
"start": "concurrently \"npm run tsc:w\" \"npm run http\" ",
"tsc": "tsc -p .",
"tsc:w": "tsc -w -p .",
"lite": "nano-server",
"http": "http-server -p 3000 -a 127.0.0.1 -o",
"typings": "typings",
"postinstall": "typings install"
},
"license": "ISC",
"dependencies": {
"@ngrx/store": "^1.3.3",
"angular2": "2.0.0-beta.9",
"es6-promise": "^3.0.2",
"es6-shim": "^0.33.3",
"reflect-metadata": "0.1.2",
"rxjs": "5.0.0-beta.2",
"systemjs": "0.19.24",
"zone.js": "0.5.15"
},
"devDependencies": {
"concurrently": "^2.0.0",
"lite-server": "^2.1.0",
"http-server": "^0.9.0",
"typescript": "^1.8.7",
"typings": "^0.7.5"
}
}
它有效。谢谢你的帮助!