簡體   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