当创建一个新的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

错误日志在这里


当前回答

简单的解决方案:

npm cache clean --force
npm install 

其他回答

我解决了这个问题,首先清理缓存使用

npm cache clean --force

Then

npm install -g @angular/cli

我的案例是Windows 7(在需要的时候没有更好的了)。 帮助我如下:

删除c:\ users \username\ appdata \ roam \npm-cache中的所有内容

AND

删除package-lock.json

我用这一行字解决了我的问题

npm cache clean --force

注意:因为它是一个干净的安装,我没有担心清空npm缓存。

如果你找npm install,得到同样的错误

删除package-lock。Json和NPM缓存清理——强制和尝试

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

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

这对我很有效