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

错误日志在这里


当前回答

你可以使用yarn包管理器而不是npm。

它为我解决了这个问题

其他回答

你可以使用yarn包管理器而不是npm。

它为我解决了这个问题

If

npm cache clean --force

是行不通的。 试一试

npm cache clean --force
npm update

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

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

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

唷!

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

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

这对我很有效