运行npm以Angular2 quickstart开始导致错误(lite-server?)

时间:2017-01-22 16:13:35

标签: node.js angular typescript

无法通过Angular2超越起跑线...出于某种原因,我无法运行精简版服务器,因为有......

  

最有可能是angular-quickstart包的问题

当我运行npm start时,我得到:

> angular-quickstart@1.0.0 start C:\xampp\htdocs\js\angular2\quickstart
> tsc && concurrently "tsc -w" "lite-server"

 Error occured when executing command: tsc -w
 Error: Unable to detect platform shell type. Please set SHELL_EXECUTE_FLAG env variable.
     at detectExecuteFlag (C:\xampp\htdocs\js\angular2\quickstart\node_modules\concurrently\node_modules\spawn-default-shell\src\get-shell.js:29:9)
     at getShell (C:\xampp\htdocs\js\angular2\quickstart\node_modules\concurrently\node_modules\spawn-default-shell\src\get-shell.js:37:18)
     at Object.spawn (C:\xampp\htdocs\js\angular2\quickstart\node_modules\concurrently\node_modules\spawn-default-shell\src\index.js:5:24)
     at C:\xampp\htdocs\js\angular2\quickstart\node_modules\concurrently\src\main.js:192:34
     at arrayMap (C:\xampp\htdocs\js\angular2\quickstart\node_modules\lodash\lodash.js:660:23)
     at Function.map (C:\xampp\htdocs\js\angular2\quickstart\node_modules\lodash\lodash.js:9571:14)
     at run (C:\xampp\htdocs\js\angular2\quickstart\node_modules\concurrently\src\main.js:181:22)
     at main (C:\xampp\htdocs\js\angular2\quickstart\node_modules\concurrently\src\main.js:61:5)
     at Object.<anonymous> (C:\xampp\htdocs\js\angular2\quickstart\node_modules\concurrently\src\main.js:421:1)
     at Module._compile (module.js:409:26)
     at Object.Module._extensions..js (module.js:416:10)
     at Module.load (module.js:343:32)
     at Function.Module._load (module.js:300:12)
     at Function.Module.runMain (module.js:441:10)
     at startup (node.js:139:18)
     at node.js:968:3

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 v4.4.7
npm ERR! npm  v2.15.8
npm ERR! code ELIFECYCLE
npm ERR! angular-quickstart@1.0.0 start: `tsc && concurrently "tsc -w" "lite-server" `
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the angular-quickstart@1.0.0 start script 'tsc && concurrently "tsc -w" "lite-server" '.
npm ERR! This is most likely a problem with the angular-quickstart package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     tsc && concurrently "tsc -w" "lite-server"
npm ERR! You can get information on how to open an issue for this project with:
npm ERR!     npm bugs angular-quickstart
npm ERR! Or if that isn't available, you can get their info via:
npm ERR!
npm ERR!     npm owner ls angular-quickstart
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR!     C:\xampp\htdocs\js\angular2\quickstart\npm-debug.log

这是npm_debug.log文件

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   'start' ]
2 info using npm@2.15.8
3 info using node@v4.4.7
4 verbose run-script [ 'prestart', 'start', 'poststart' ]
5 info prestart angular-quickstart@1.0.0
6 info start angular-quickstart@1.0.0
7 verbose unsafe-perm in lifecycle true
8 info angular-quickstart@1.0.0 Failed to exec start script
9 verbose stack Error: angular-quickstart@1.0.0 start: `tsc && concurrently "tsc -w" "lite-server" `
9 verbose stack Exit status 1
9 verbose stack     at EventEmitter.<anonymous> (C:\Program Files\nodejs\node_modules\npm\lib\utils\lifecycle.js:217:16)
9 verbose stack     at emitTwo (events.js:87:13)
9 verbose stack     at EventEmitter.emit (events.js:172:7)
9 verbose stack     at ChildProcess.<anonymous> (C:\Program Files\nodejs\node_modules\npm\lib\utils\spawn.js:24:14)
9 verbose stack     at emitTwo (events.js:87:13)
9 verbose stack     at ChildProcess.emit (events.js:172:7)
9 verbose stack     at maybeClose (internal/child_process.js:827:16)
9 verbose stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:211:5)
10 verbose pkgid angular-quickstart@1.0.0
11 verbose cwd C:\xampp\htdocs\js\angular2\quickstart
12 error Windows_NT 10.0.14393
13 error argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "start"
14 error node v4.4.7
15 error npm  v2.15.8
16 error code ELIFECYCLE
17 error angular-quickstart@1.0.0 start: `tsc && concurrently "tsc -w" "lite-server" `
17 error Exit status 1
18 error Failed at the angular-quickstart@1.0.0 start script 'tsc && concurrently "tsc -w" "lite-server" '.
18 error This is most likely a problem with the angular-quickstart package,
18 error not with npm itself.
18 error Tell the author that this fails on your system:
18 error     tsc && concurrently "tsc -w" "lite-server"
18 error You can get information on how to open an issue for this project with:
18 error     npm bugs angular-quickstart
18 error Or if that isn't available, you can get their info via:
18 error
18 error     npm owner ls angular-quickstart
18 error There is likely additional logging output above.
19 verbose exit [ 1, true ]

这个东西并不容易!

4 个答案:

答案 0 :(得分:10)

当我尝试npm从git bash从angular 2网站启动Quickstart repo时,发生了类似的问题。

我找到的解决方案是:

1。)更新您的SHELL env变量 export SHELL =&#34; / c / Program Files / Git / bin / bash&#34;

2。)从Quickstart仓库导航到node_module / spawn-default-shell / src / get-shell.js。打开get-shell.js并进行以下更改:

const DETECT_SH_REGEX = / sh $ /;

const DETECT_SH_REGEX = / sh /;

可以从github上的以下问题页面找到完整的解释: https://github.com/angular/quickstart/issues/359

答案 1 :(得分:4)

任何人遇到此问题并使用Windows git bash,请尝试使用Windows CLI。

答案 2 :(得分:0)

更改Package.json脚本设置

"start": "tsc && concurrently \"npm run tsc:w\" \"npm run lite\",

"start": "concurrently \"npm run tsc:w\" \"npm run lite\" ",

答案 3 :(得分:0)

输入bash或cli:ng serve --open

参考:https://angular.io/guide/quickstart