1.打开命令行:输入:
npm config ls 看默认安装路径
npm config set prefix "your setting path" 设置路径,如:"D:\local software manager\download\node\node local resposity"
npm config get cache 查看缓存路径
npm config set cache "D:\nodejs\node_cache" 更改缓存路径
2.更换成淘宝镜像cnpm,输入:
npm config set registry https://registry.npm.taobao.org
npm install -g cnpm --registry=https://registry.npm.taobao.org
然后配置cnpm的环境变量,若cnpm所在路径为:
“D:\local software manager\download\node\node local resposity\cnpm”
则环境变量的路径为:"D:\local software manager\download\node\node local resposity"
npm config get registry
运行npm命令报错:
Error: EPERM: operation not permitted, mkdir 'C:\Program Files\nodejs\node_global"
解决:
删除C:\Users{你的用户文件夹}/目录中的.npmrc文件,如下