idea npm install 很慢(nodejs)
npm install 速度慢的问题通常可以通过配置国内镜像源、清理缓存或切换工具解决。以下是具体方法:
配置国内镜像源
推荐使用淘宝NPM镜像(https://registry.npmmirror.com),通过命令设置全局镜像源:
npm config set registry https://registry.npmmirror.com
若需临时使用,可在安装命令中添加参数:
npm install --registry=https://registry.npmmirror.com
显示详细日志以定位问题(--verbose)
npm install --registry=https://registry.npmmirror.com --verbose
清理缓存
运行以下命令强制清理缓存:
npm cache clean --force