繁体   English   中英

npm 错误。 在“...tore-4.0.0,tgz”,“文件”附近解析时输入意外结束 JSON

[英]npm ERR! Unexpected end of JSON input while parsing near '...tore-4.0.0.tgz","file'

我在 windows 7 和现在 Ubuntu 19.10 遇到了这个问题。 我刚刚完成 PC 的格式化并设置了开发环境。 任何人都可以帮忙吗?

节点 v12.16.2

npm v6.14.4

npm install -g gatsby-cli

npm WARN deprecated core-js@2.6.11: core-js@<3 is no longer maintained and not recommended for usage due to the number of issues. Please, upgrade your dependencies to the actual version of core-js@3.
npm ERR! Unexpected end of JSON input while parsing near '...tore-4.0.0.tgz","file'
npm ERR! A complete log of this run can be found in:
npm ERR!     /home/rodrigo/.npm/_logs/2020-04-14T03_11_30_986Z-debug.log

当重试运行npm install -g gatsby-cli时,会发生以下情况:

npm ERR! Response timeout while trying to fetch https://registry.npmjs.org/emoji-regex (over 30000ms)

这里有两个问题。 第一个,关于 所以当你连接中断并且你在安装过程中正在解析其中一些 JSON 文件时,就会发生这种情况。 他们应该自动修理,但有时您需要:

npm cache clean --force --强制手动清除缓存。

第二个是因为您没有设置注册表来从中提取包。 npm config set registry "https://registry.npmjs.com/"然后你需要重新安装npm install -g gatsby-cli

我必须更改 npm 的注册表。

npm config set registry "https://registry.npmjs.com/"

然后清除缓存。

npm cache clean --force

最后运行 gatsby 安装程序。

npm install -g gatsby-cli

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM