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

npm i npm@latest -g

然后通常使用NPM安装命令

npm install 

其他回答

你可以设置一个临时文件夹,而不是清除缓存:

npm install --cache /tmp/empty-cache

or

npm install --global --cache /tmp/empty-cache

从npm@5开始,npm缓存会从损坏问题中自我修复,并且从缓存中提取的数据保证是有效的。如果你想确保所有内容都是一致的,可以使用npm缓存验证。另一方面,如果你正在调试安装程序的问题,你可以使用npm install——cache /tmp/empty-cache来使用一个临时缓存,而不是破坏实际的缓存。

If

npm cache clean --force

是行不通的。 试一试

npm cache clean --force
npm update

以管理员身份打开windows PowerShell或CMD

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

如果这行不通,试试下面的方法

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

NPM缓存清理——强制对我有用

错误解决:

$ NPM install -g gulp npm WARN已弃用gulp-util@3.0.8: gulp-util已弃用—替换它,请遵循https://medium.com/gulpjs/gulp-util-ca3b1f9f9ac5上的指导方针 npm犯错!解析JSON输入时意外结束'…/RGs88STtAtiMP3tCiNdU'

npm犯错!这个运行的完整日志可以在下面找到: npm犯错!C:\Users\admin\AppData\Roaming\ npm-cache_logs \ 2018 - 11 - 20 - t07_38_56_733z debug.log

我用

首先删除package-lock.json

npm cache clean --force

然后更新NPM

npm i npm@latest -g

然后使用NPM安装命令

npm install