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

所以卸载节点并重新安装它。

它的工作原理……

PS:重新安装node后,全局安装angular cli。

npm install -g @angular/cli@latest

其他回答

解决方案

npm cache clean --force

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

npm install && npm start

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

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

我用

首先删除package-lock.json

npm cache clean --force

然后更新NPM

npm i npm@latest -g

然后使用NPM安装命令

npm install 

这是来自npm....的错误

所以卸载节点并重新安装它。

它的工作原理……

PS:重新安装node后,全局安装angular cli。

npm install -g @angular/cli@latest
npm uninstall -g angular-cli

npm cache clear --force

OR

删除此文件夹目录(Windows)

rmdir C:\Users\<ProfileName>\AppData\Roaming\npm
rmdir C:\Users\<ProfileName>\AppData\Roaming\npm-cache