解決科學上網下使用 NPM

4年前 (2020-02-16) Yosheng 科學上網, 資訊教學 0評論 已收錄 1507℃

在中國境內很多人會使用 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:443

npm 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

嘗試關閉使用代理出現如下圖錯誤


那麼就換嘗試使用代理,輸入下列指令

再進行安裝即可

博主

擅長使用 C# 和 Java 開發項目,全棧開發工程師,前端主要使用 Vue 其次 Angular ,目前正在學習分布式架構,運維研發兼具,平時愛好鑽研技術並應用於實務當中,常駐於上海。

相關推薦

相逢就是有緣,留下足跡吧!