npm i 安装遇到问题
简介
在Node.js开发过程中,npm install 是安装和管理项目依赖的关键命令。然而,有时我们会遇到 npm install 运行卡住不动的情况,这通常与网络连接、NPM源的可用性和速度、资源下载超时等因素有关。
1.使用国内镜像【淘宝镜像】安装
下载淘宝镜像命令
npm config set registry https://registry.npmmirror.com
2.清楚缓存并重新安装
npm cache clean --force
npm install
- 设置HTTP(S)代理
npm config set proxy http://proxy.example.com:8080
npm config set https-proxy http://proxy.example.com:8080
//需要将地址改为实际的代理服务器地址和端口
4.查询日志以便于定位问题
npm install --verbose
5.查询日志找到问题后,可独立安装某个包
npm install <package-name>
6.更新NPM版本
npm install -g npm