当创建一个新的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 ERR!解析JSON输入时意外结束“…ore-js”:“3.0.0-beta.1 .

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

npm cache clean --force

其他回答

如果npm cache clean——force不能解决这个问题,试着删除~/。npm目录(*nix/macOS)。这个目录存放node的缓存、锁、日志、全局包(除非你使用nvm)和通过npx安装的模块。

首先,备份当前的~/。npm目录:

mv ~/.npm ~/.npm-backup

现在再次尝试运行你的npm命令。这将创建一个新的~/。npm目录。如果问题已解决,您可以安全地删除备份。在这样做之前,您可能需要检查安装在~/中的全局包。所以你可以使用NPM I -g [package]重新安装它们。

rm -rf ~/.npm-backup

如果问题没有解决,您可以恢复备份:

rm -rf ~/.npm
mv ~/.npm-backup ~/.npm

小心那些rm命令,伙计们!

这为我解决了问题:

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

NPM缓存清理——强制对我有用

错误解决:

$ NPM install -g gulp npm WARN已弃用gulp-util@3.0.8: gulp-util已弃用—替换它,请遵循https://medium.com/gulpjs/gulp-util-ca3b1f9f9ac5上的指导方针 npm犯错!解析JSON输入时意外结束'…/RGs88STtAtiMP3tCiNdU'

npm犯错!这个运行的完整日志可以在下面找到: npm犯错!C:\Users\admin\AppData\Roaming\ npm-cache_logs \ 2018 - 11 - 20 - t07_38_56_733z debug.log

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

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 +流产+安装。

我遇到过这个问题,我尝试了Stackoverflow上的所有答案,但不适合我,最后我找到了这个问题的解决方案:

首先,你必须卸载nodejs,并删除所有与他相关的文件 进入“注册编辑器”,搜索所有“nodejs”,“node.js”并删除它们 重新启动计算机 重新安装nodejs,然后安装angular。

这对我很有效