共计 1056 个字符,预计需要花费 3 分钟才能阅读完成。
在中國境內很多人會使用 cnpm 來下載前端套件相關依賴,cnpm 不過就是 npm 鏡像,本篇筆記如何透過科學上網工具來使用 npm。
如果直接使用 npm install 可能會遇到下列錯誤如下
npm WARN [email protected] No repository field.
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: [email protected] (node_modules\asap):
npm WARN network SKIPPING OPTIONAL DEPENDENCY: request to https://registry.npmjs.org/asap/-/asap-2.0.6.tgz failed, reason: connect ETIMEDOUT 198.18.0.57:443npm ERR! code ETIMEDOUT
npm ERR! errno ETIMEDOUT
npm ERR! network request to https://registry.npmjs.org/async-foreach/-/async-foreach-0.1.3.tgz failed, reason: connect ETIMEDOUT 198.18.0.57:443
npm ERR! network This is a problem related to network connectivity.
npm ERR! network In most cases you are behind a proxy or have bad network settings.
npm ERR! network
npm ERR! network If you are behind a proxy, please make sure that the
npm ERR! network ‘proxy’ config is set properly. See: ‘npm help config’npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\Yo-Sheng\AppData\Roaming\npm-cache\_logs\2020-02-11T12_49_15_488Z-debug.log
嘗試關閉使用代理出現如下圖錯誤
那麼就換嘗試使用代理,輸入下列指令
npm config set proxy http://127.0.0.1: 翻牆端口
再進行安裝即可