建立 nuxt3 項目時發生錯誤。無法從登錄下載模板
P粉469090753
P粉469090753 2023-11-01 23:50:03
0
2
747

當我使用此命令建立新的 Nuxt 3 專案時:

npx nuxi init nuxt-app

它輸出此錯誤:

ERROR  (node:1752) ExperimentalWarning: The Fetch API is an experimental feature. This feature could change at any time                         09:53:25
(Use `node --trace-warnings ...` to show where the warning was created)


 ERROR  Failed to download template from registry: fetch failed                                                                                  09:53:25

  at /C:/Users/myname/AppData/Local/npm-cache/_npx/a95e0f536cf9a537/node_modules/nuxi/dist/chunks/init.mjs:13269:11
  at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
  at async downloadTemplate (/C:/Users/myname/AppData/Local/npm-cache/_npx/a95e0f536cf9a537/node_modules/nuxi/dist/chunks/init.mjs:13268:20)
  at async Object.invoke (/C:/Users/myname/AppData/Local/npm-cache/_npx/a95e0f536cf9a537/node_modules/nuxi/dist/chunks/init.mjs:13336:15)
  at async _main (/C:/Users/myname/AppData/Local/npm-cache/_npx/a95e0f536cf9a537/node_modules/nuxi/dist/cli.mjs:50:20)

我的環境:

  • 作業系統:Windows 11
  • 節點版本:18.12.0
  • #
  • npm 版本:8.12.1

起初我懷疑這是由於我的網路造成的。但是當我嘗試安裝其他 npm 套件時沒有收到錯誤。

P粉469090753
P粉469090753

全部回覆(2)
P粉287345251

我也遇到了同樣的錯誤(Windows 10)。我的很簡單。

ERROR  Error: Failed to download template from registry: fetch failed

是的,這與網路或IP被封鎖有關。不過我還是設法解決了。這就是我所做的。

先進入C:\Windows\System32\drivers\etc

#在此資料夾中尋找「hosts」檔案。用記事本以管理員身份開啟。現在在文件末尾(以及其他 IP 位址)添加此行。

// Some other ip address
185.199.108.133 raw.githubusercontent.com

這應該可以解決問題。

P粉633075725

我在這裡找到了原因。

確實是網路問題。它無法從命令列存取 raw.githubusercontent.com,因為它找不到相應的 IP 位址。

raw.githubusercontent.com 的正確 IP 位址新增至 Windows 主機檔案後,問題已修正

熱門教學
更多>
最新下載
更多>
網站特效
網站源碼
網站素材
前端模板
關於我們 免責聲明 Sitemap
PHP中文網:公益線上PHP培訓,幫助PHP學習者快速成長!