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

错误日志在这里


当前回答

删除C:\Users\admin\AppData\Roaming\ (windows)目录下的npm和npm-cache文件夹 然后执行CMD

NPM缓存清除——force NPM缓存验证

更新NPM到最新版本

npm啊,g pm

然后创建项目 1)角

npm i -g @angular/cli@latest 新的你好世界

2)反应

NPM I -g create-react-app create-react-app react-app

其他回答

我用这一行字解决了我的问题

npm cache clean --force

注意:因为它是一个干净的安装,我没有担心清空npm缓存。

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 install,得到同样的错误

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

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

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

它的工作原理……

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

npm install -g @angular/cli@latest