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

错误日志在这里


这为我解决了问题:

以管理员身份打开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缓存。 使用以下命令进行清洁:

npm cache clean --force

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

npm install -g @angular/cli

我用

npm cache clean --force

然后更新NPM

npm i npm@latest -g

然后通常使用NPM安装命令

npm install 

解决方案:

npm cache clean --force

然后再尝试创建你的应用程序(这里创建一个react应用程序)或安装你要安装的东西。

create-react-app myproject

(创建react应用程序)[在不同的操作中可能出现相同的NPM问题]

npm install -g @angular/cli@latest

(安装angular cli(或安装其他任何东西))

它会起作用的。

解释:

这是一个与npm相关的问题,它是关于缓存被破坏的。即使在npm的新版本中,他们实现了自我修复,这通常保证没有损坏,但似乎效率不高。 强制清理缓存可以解决这个问题。

该错误发生在解析一个缓存文件时,该文件具有json格式。缓存位于~/。npm/ _cache (linux)和%AppData%/npm-cache (windows)。对于我当前的npm版本,当我检查时,有三个目录。

如果你检查第一个或第二个,结构如下

每个缓存文件都有json格式

这里有一个很好的文档链接:https://docs.npmjs.com/cli/cache

[更新]如果这没有解决问题,你可以在这里检查这个答案https://stackoverflow.com/a/50191315/7668448它展示了你如何改变npm注册表,这可能是有帮助的。检查一下。

这解决了它NPM缓存清理-力

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

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

它的工作原理……

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

npm install -g @angular/cli@latest

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

If

npm cache clean --force

是行不通的。 试一试

npm cache clean --force
npm update

删除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

此外,您还应该确保使用了正确的节点版本。

使用nvm管理节点版本:

nvm list; # check your local versions;
nvm install 10.10.0; # install a new remote version;
nvm alias default 10.10.0; # set the 10.10.0 as the default node version, but you have to restart the terminal to make it take effect;

解决方案

npm cache clean --force

Windows:进入“c:\ users \username\ appdata \ roam \npm-cache”目录 删除所有文件并运行

npm install && npm start

简单的解决方案:

npm cache clean --force
npm install 

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

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

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 cache clean --force

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

我用

首先删除package-lock.json

npm cache clean --force

然后更新NPM

npm i npm@latest -g

然后使用NPM安装命令

npm install 

在这个npm缓存清理——force之后

也许你可以挂断或等待进一步执行

我真的希望你知道你在做什么。

你也可以用这个。这就解决了我的问题。

NPM install——cache /tmp/empty-cache

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

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

npm cache clean --force

在运行以下代码后,我得到了错误(文件已经存在——强制覆盖):

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

我用:

npm i -g --force npm

确保运行第一个命令来刷新npm的缓存。

我解决了这个问题,首先清理缓存使用

npm cache clean --force

Then

npm install -g @angular/cli

对我来说,我不得不再次克隆我的分支,并进行npm安装

你可以使用yarn包管理器而不是npm。

它为我解决了这个问题

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

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

这对我很有效

如果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命令,伙计们!

这些命令对我很管用

sudo npm cache clean --force

sudo npm cache verify

sudo npm i npm@latest -g

我的案例是Windows 7(在需要的时候没有更好的了)。 帮助我如下:

删除c:\ users \username\ appdata \ roam \npm-cache中的所有内容

AND

删除package-lock.json

尝试设置

NPM配置strict-ssl为false

然后试着跑步,

NPM install -g @angular/cli

由于缓存或节点包管理器的过时版本,会发生这种情况 我刚刚更新了我的NPM,它工作得很好 下面是更新Npm到最新版本的命令

npm i npm@latest -g

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

即使npm缓存清理——force

尝试执行admin文件夹下的安装cmd。 即 C:\Users\admin 这对我来说很有效。

在解析JSON输入时遇到了意想不到的结束问题。而在我的React应用程序中添加“镭”包。事实上,我甚至在尝试将NPM更新到最新版本时也面临着这个问题。

不管怎样,NPM在清除缓存后无法工作,现在也不会更新到最新版本,但通过Yarn添加包对我来说是有效果的。

所以,如果你急于解决这个问题,但你不能,那么试试yarn,而不是npm。

编码快乐!

更新

在尝试了一些事情后,最后sudo npm缓存清理-force为我工作。

这可能是你的网络或npm注册表中的其他东西的临时故障。

npm uninstall -g angular-cli

npm cache clear --force

OR

删除此文件夹目录(Windows)

rmdir C:\Users\<ProfileName>\AppData\Roaming\npm
rmdir C:\Users\<ProfileName>\AppData\Roaming\npm-cache

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

如果你找npm install,得到同样的错误

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

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

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

这里的30个答案都不适合我。我需要:

删除node_modules和package-lock.json NPM缓存清理——force NPM install -g @angular/cli NPM I——仅包锁 npm ci

唷!

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

npm cache clean --force

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

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

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

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

每个人都在说

npm cache clean --force

但如果这行不通,那就按照下面的步骤来做。

重新安装npm:重新安装npm有时可以解决与npm本身的冲突和其他问题。要重新安装npm,请执行以下步骤:

Uninstall npm:

npm uninstall -g npm

删除npm缓存文件夹:

npm cache clean --force

安装包支持的新LTS节点。如果节点版本不支持,执行以下命令重新安装npm时可能会收到错误。这是你可能得到的错误类型:

npm犯错!notsup要求:{“节点”:“^ 14.17.0 | | ^ 16.13.0 | | > = 18.0.0 "}

npm犯错!notsup Actual: {"npm":"9.4.0","node":"v16.0.0"}

这样你就可以逃跑了,就像我一样

nvm i 16.13.0

其中“i”是“install”的缩写,和

nvm install 16.13.0

然后重新安装npm:

npm install -g npm

如果上面的方法不管用……您应该尝试下面的步骤

删除node_modules文件夹和package-lock。node_modules文件夹和包锁。Json文件有时会被损坏,导致安装包时出错。要解决这个问题,你可以尝试删除这些文件,然后重新安装你的包:

删除node_modules文件夹:

rm -rf node_modules

删除包锁。json文件:

rm package-lock.json

重新安装软件包:

npm install

ELSE

Use a different version of Node.js: If you are encountering errors while using a specific version of Node.js, you can try switching to a different version to see if the issue is resolved. You can use a version manager such as nvm to manage different versions of Node.js on your system. Check for malware or virus: If you are still encountering issues, there may be malware or a virus on your system that is interfering with npm. Check your system for malware or viruses and remove any that are found.