当创建一个新的Angular 5项目时:

节点版本号:8.9.2

NPM版本:5.5.1

我的命令是:

npm install -g @angular/cli

错误是:

npm ERR! **Unexpected end of JSON input while parsing near '...nt-webpack-plugin":"0'**
npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\Aashitec\AppData\Roaming\npm-cache\_logs\2017-12-06T13_10_10_729Z-debug.log

错误日志在这里


当前回答

我用

首先删除package-lock.json

npm cache clean --force

然后更新NPM

npm i npm@latest -g

然后使用NPM安装命令

npm install 

其他回答

这为我解决了问题:

以管理员身份打开Windows Powershell

npm cache clean --force
npm install -g @angular/cli

https://devblogs.microsoft.com/premier-developer/getting-started-with-node-js-angular-and-visual-studio-code/

简单的解决方案:

npm cache clean --force
npm install 

这里的30个答案都不适合我。我需要:

删除node_modules和package-lock.json NPM缓存清理——force NPM install -g @angular/cli NPM I——仅包锁 npm ci

唷!

在这个npm缓存清理——force之后

也许你可以挂断或等待进一步执行

我真的希望你知道你在做什么。

你也可以用这个。这就解决了我的问题。

NPM install——cache /tmp/empty-cache

我遇到过这个问题,我尝试了Stackoverflow上的所有答案,但不适合我,最后我找到了这个问题的解决方案:

首先,你必须卸载nodejs,并删除所有与他相关的文件 进入“注册编辑器”,搜索所有“nodejs”,“node.js”并删除它们 重新启动计算机 重新安装nodejs,然后安装angular。

这对我很有效