當我使用此命令創建一個新的 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 包時,我沒有收到錯誤訊息。
uj5u.com熱心網友回復:
我在客戶(銀行)作業時遇到了同樣的問題,這確實主要是網路限制。他們只限制了對少數 NPM 包的訪問,而這個包沒有被列入白名單(主要是模板)。
除了使用 SSH/HTTP 克隆手動獲取代碼或可能要求他們允許該特定端點之外,不確定如何正確繞過它。
uj5u.com熱心網友回復:
我在這里找到了原因。
確實是網路問題。它無法raw.githubusercontent.com從命令列訪問,因為它找不到相應的 IP 地址。
將正確的 IP 地址添加raw.githubusercontent.com到 Windows 主機檔案后,問題已修復
轉載請註明出處,本文鏈接:https://www.uj5u.com/caozuo/528168.html
