运行npm install 时,卡住不动,四种解决方法

检查网络设置,删除node_modules重新npm install

(1)配置npm代理

// 配置nmp代理来提高速度,如设置淘宝镜像
npm config set registry https://registry.npm.taobao.org

// 查看配置是否成功
npm config get registry

// 成功后重新npm install安装
npm install

(2)使用nrm来管理npm镜像源

// 全局安装nrm (mac需要加上sudo)
npm install -g nrm

// 查看可配置的源列表
nrm ls

// 使用配置列表中的源
nrm use taobao
使用cnpm来安装

(3)全局安装cnpm (mac需要加上sudo)

// 全局安装cnpm (mac需要加上sudo)
npm install cnpm -g --registry=https://registry.npmmirror.com

// 成功后使用cnpm install安装
cnpm install

(4)使用yarn来安装

// 全局安装yarn (mac需要加上sudo)
npm install -g yarn

// 成功后使用yarn install安装
yarn install