共计 596 个字符,预计需要花费 2 分钟才能阅读完成。
1. 重装
检查网络设置,删除 node_modules 重新 npm install
2. 配置 npm 代理
// 配置 nmp 代理来提高速度,如设置淘宝镜像
npm config set registry https://registry.npm.taobao.org
// 查看配置是否成功
npm config get registry
// 成功后重新 npm install 安装
npm install
3. 使用 nrm 来管理 npm 镜像源
// 全局安装 nrm (mac 需要加上 sudo)
npm install -g nrm
// 查看可配置的源列表
nrm ls
// 使用配置列表中的源
nrm use taobao
// 成功后重新 npm install 安装
npm install
4. 使用 cnpm 来安装
// 全局安装 cnpm (mac 需要加上 sudo)
npm install cnpm -g --registry=https://registry.npmmirror.com
// 成功后使用 cnpm install 安装
cnpm install
5. 使用 yarn 来安装
// 全局安装 yarn (mac 需要加上 sudo)
npm install -g yarn
// 成功后使用 yarn install 安装
yarn install
6. 使用 pnpm 来安装
// 全局安装 pnpm
npm install -g pnpm
// 成功后使用 pnpm install 安装
pnpm install
原文地址: npm install 卡住不动的六种解决方法
正文完