当创建一个新的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,它工作得很好 下面是更新Npm到最新版本的命令

npm i npm@latest -g

更新NPM后运行你想要的命令

其他回答

Npm使用缓存下载新包。 你需要清除你的npm缓存。 使用以下命令进行清洁:

npm cache clean --force

然后通常使用NPM安装命令 如。

npm install -g @angular/cli

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

npm cache clean --force

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

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

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

npm cache clean --force

首先卸载现有的npm包: NPM卸载-g create-react-app(如果是全局安装) 其次: NPM缓存清理——force 第三: NPM install -g create-react-app@latest并重新创建-react-app my-app。

这为我解决了问题:

以管理员身份打开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/