角度 2 - npm 错误

Posted

技术标签:

【中文标题】角度 2 - npm 错误【英文标题】:angular 2 - npm error 【发布时间】:2016-05-26 13:04:17 【问题描述】:

我正在关注5 Min Quickstart - js - Angular 2 指南,但在调用“npm start”后遇到了一个奇怪的错误:

> angular2-quickstart@1.0.0 start C:\Users\stavalfi\Desktop\plunkerExample
> npm run lite


> angular2-quickstart@1.0.0 lite C:\Users\stavalfi\Desktop\plunkerExample
> lite-server

'lite-server' is not recognized as an internal or external command,
operable program or batch file.

npm ERR! Windows_NT 6.1.7601
npm ERR! argv "C:\\Program Files (x86)\\nodejs\\\\node.exe" "C:\\Program Files (x86)\\nodejs\\node_modules\\npm\\bin\\npm-cli.js
" "run" "lite"
npm ERR! node v0.12.2
npm ERR! npm  v2.7.4
npm ERR! code ELIFECYCLE
npm ERR! angular2-quickstart@1.0.0 lite: `lite-server`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the angular2-quickstart@1.0.0 lite script 'lite-server'.
npm ERR! This is most likely a problem with the angular2-quickstart package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     lite-server
npm ERR! You can get their info via:
npm ERR!     npm owner ls angular2-quickstart
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR!     C:\Users\stavalfi\Desktop\plunkerExample\npm-debug.log

npm ERR! Windows_NT 6.1.7601
npm ERR! argv "C:\\Program Files (x86)\\nodejs\\\\node.exe" "C:\\Program Files (x86)\\nodejs\\node_modules\\npm\\bin\\npm-cli.js
" "start"
npm ERR! node v0.12.2
npm ERR! npm  v2.7.4
npm ERR! code ELIFECYCLE
npm ERR! angular2-quickstart@1.0.0 start: `npm run lite`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the angular2-quickstart@1.0.0 start script 'npm run lite'.
npm ERR! This is most likely a problem with the angular2-quickstart package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     npm run lite
npm ERR! You can get their info via:
npm ERR!     npm owner ls angular2-quickstart
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR!     C:\Users\stavalfi\Desktop\plunkerExample\npm-debug.log

更新:安装“npm install lite-server -g”时,出现以下错误:

MSBUILD : error MSB3428: Could not load the Visual C++ component "VCBuild.exe". To fix this, 1) install the .NET Framework 2.0 
SDK, 2) install Microsoft Visual Studio 2005 or 3) add the location of the component to the system path if it is installed else
where.  [C:\Users\stavalfi\AppData\Roaming\npm\node_modules\lite-server\node_modules\browser-sync\node_modules\socket.io\node_m
odules\engine.io\node_modules\ws\node_modules\utf-8-validate\build\binding.sln]
gyp ERR! build error
gyp ERR! stack Error: `C:\Program Files (x86)\MSBuild\14.0\bin\msbuild.exe` failed with exit code: 1
gyp ERR! stack     at ChildProcess.onExit (C:\Program Files (x86)\nodejs\node_modules\npm\node_modules\node-gyp\lib\build.js:269
:23)
gyp ERR! stack     at ChildProcess.emit (events.js:110:17)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (child_process.js:1074:12)
gyp ERR! System Windows_NT 6.1.7601
gyp ERR! command "node" "C:\\Program Files (x86)\\nodejs\\node_modules\\npm\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild"

gyp ERR! cwd C:\Users\stavalfi\AppData\Roaming\npm\node_modules\lite-server\node_modules\browser-sync\node_modules\socket.io\nod
e_modules\engine.io\node_modules\ws\node_modules\utf-8-validate
gyp ERR! node -v v0.12.2
gyp ERR! node-gyp -v v1.0.3
gyp ERR! not ok

> bufferutil@1.2.1 install C:\Users\stavalfi\AppData\Roaming\npm\node_modules\lite-server\node_modules\browser-sync\node_modules
\socket.io\node_modules\engine.io\node_modules\ws\node_modules\bufferutil
> node-gyp rebuild

【问题讨论】:

【参考方案1】:

错误代码ENOENT 表示“没有这样的文件或目录”。

您应该检查您是否有文件 C:\Users\stavalfi\package.json 存在并可供应用程序访问...您是否在正确的文件夹中执行命令?

【讨论】:

包没有放在正确的位置。但现在我得到了新的错误。任何额外的帮助都会得到祝福! 我会说你的精简服务器没有安装在全球范围内。尝试使用-g 选项:npm install lite-server -g 这样做并得到了一些奇怪的错误。我确实有 VS 2015,我认为它带有 C++ 编译器。【参考方案2】:

您是否尝试过更新 npm?我在 5 分钟快速启动时遇到了一些其他问题,但在我更新 npm 后,我可以运行 npm start 而没有任何错误。

【讨论】:

以上是关于角度 2 - npm 错误的主要内容,如果未能解决你的问题,请参考以下文章

我被这个错误困住了。当我按照所有步骤在heroku上部署角度应用程序时

ng --version 显示错误的角度版本

启动角度项目时错误连接被拒绝

启动角度项目时拒绝连接错误

由于错误无法构建角度项目:错误输出为:不推荐使用选项“vendorSourceMap”

npm 包有依赖错误,即使在我手动安装它们之后