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

它为我解决了这个问题

其他回答

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

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

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

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

If

npm cache clean --force

是行不通的。 试一试

npm cache clean --force
npm update

这些命令对我很管用

sudo npm cache clean --force

sudo npm cache verify

sudo npm i npm@latest -g

我使用Windows并删除了下面列出的所有文件,我的问题就解决了 C: \用户{{你的用户名}}\ AppData \ \ npm-cache徘徊

错误:npm ERR!解析JSON输入时意外结束“…ore-js”:“3.0.0-beta.1 .

这发生在全局安装expo CLI时,这对我有用!

npm cache clean --force