鍍金池/ 問答/Linux  網(wǎng)絡(luò)安全/ npm和yarn都不能使用

npm和yarn都不能使用

一、使用yarn
1、安裝好后更換淘寶鏡像

yarn config set registry https://registry.npm.taobao.org

2、使用yarn進(jìn)行包的安裝,出現(xiàn)如下錯誤:

$ yarn install
yarn install v1.3.2
info No lockfile found.
[1/4] Resolving packages...
[2/4] Fetching packages...
info There appears to be trouble with your network connection. Retrying...
info There appears to be trouble with your network connection. Retrying...
info There appears to be trouble with your network connection. Retrying...
info There appears to be trouble with your network connection. Retrying...

二、使用npm
1、安裝好node.js 8.9.3后更換國內(nèi)鏡像
更換方法:在電腦個人用戶目錄下的新建.npmrc文件,寫入下面內(nèi)容:

registry=http://registry.cnpmjs.org/
sass_binary_site=https://npm.taobao.org/mirrors/node-sass/

2、使用npm進(jìn)行包的安裝,下面卡死了

PS D:\wnmp\www\myproject> npm install
[ .................] - fetchMetadata: sill pacote range manifest for lodash.escape@^3.0.0 fetched in 203ms

問題:
npm和yarn都不能使用,哪里沒有設(shè)置正確?

回答
編輯回答
枕頭人
  1. 全局安裝nrm: npm install nrm -g;
  2. 查看鏡像源: nrm ls;
  3. 切換鏡像源: nrm use taobao; // 我用的淘寶
  4. 安裝需要的模塊: npm install <package-name>;
  5. 如果需要安裝全部依賴: npm install;

// 有問題再call我

2017年7月30日 04:03
編輯回答
遲月

npm用淘寶源,cnpmjs也是在國外的

2018年1月5日 09:03