当创建一个新的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 cache clean --force
npm install 

其他回答

If

npm cache clean --force

是行不通的。 试一试

npm cache clean --force
npm update

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

npm cache clean --force

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

你可以设置一个临时文件夹,而不是清除缓存:

npm install --cache /tmp/empty-cache

or

npm install --global --cache /tmp/empty-cache

从npm@5开始,npm缓存会从损坏问题中自我修复,并且从缓存中提取的数据保证是有效的。如果你想确保所有内容都是一致的,可以使用npm缓存验证。另一方面,如果你正在调试安装程序的问题,你可以使用npm install——cache /tmp/empty-cache来使用一个临时缓存,而不是破坏实际的缓存。

在我的例子中,我把网络换成了一个更强大的网络,npm安装工作得很好:

npm cache clean --force

这个错误可能是由许多不同的原因引起的。也许你的全局包以某种方式损坏了,我建议执行以下操作。

1 Install Node Version Manager (or NVM for Windows) and install Node version 10.16.1. This is enough for angular 9 and from my experience, it is the most stable version for development. This should also change your NPM version so that may also help.

2 Uninstall global angular package npm uninstall -g @angular/cli

3 Force clear cache npm cache clean --force

4 You can also try clearing your %temp% and %roaming% AppData/npm-cache

5 install latest angular package npm install -g @angular/cli@<your-version>

6 if this error still occurs, consider using another shell.

源- https://www.codegrepper.com/code-examples/javascript/npm +犯错% 21 +意外+终端+ + JSON +输入+ +分析+在+ % 27时…babel-plugin-istanbul % 27 + npm +犯错% 21 + + +日志+完整的+ + + +可以运行+发现+ % 3 + npm +犯错% 21 + 3 C % % 5 cusers % 5 csapho % 5 cappdata % 5 croaming % 5 cnpm-cache % 5 c_logs % 5 c2020-08-26t20_37_45_303z-debug.log +流产+安装。