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

其他回答

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

npm cache clean --force

Then

npm install -g @angular/cli

这为我解决了问题:

以管理员身份打开Windows Powershell

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

https://devblogs.microsoft.com/premier-developer/getting-started-with-node-js-angular-and-visual-studio-code/

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

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

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

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

在这个npm缓存清理——force之后

也许你可以挂断或等待进一步执行

我真的希望你知道你在做什么。

你也可以用这个。这就解决了我的问题。

NPM install——cache /tmp/empty-cache

If

npm cache clean --force

是行不通的。 试一试

npm cache clean --force
npm update