当创建一个新的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配置strict-ssl为false

然后试着跑步,

NPM install -g @angular/cli

其他回答

这条命令就解决了我的问题:

npm cache clean --force

此外,您还应该确保使用了正确的节点版本。

使用nvm管理节点版本:

nvm list; # check your local versions;
nvm install 10.10.0; # install a new remote version;
nvm alias default 10.10.0; # set the 10.10.0 as the default node version, but you have to restart the terminal to make it take effect;

即使npm缓存清理——force

尝试执行admin文件夹下的安装cmd。 即 C:\Users\admin 这对我来说很有效。

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

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

AND

删除package-lock.json

解决方案

npm cache clean --force

Windows:进入“c:\ users \username\ appdata \ roam \npm-cache”目录 删除所有文件并运行

npm install && npm start

简单的解决方案:

npm cache clean --force
npm install