接上文在执行报错
npm cache clean --force
npm WARN using --force Recommended protections disabled.
1.检查版本
查看node.js、npm、vue、vue脚手架、npm镜像
【node版本】
命令:node -v
结果:v18.15.0 (我目前使用的版本)
【npm版本】
命令:npm -v
结果:9.5.0
【cnpm版本】
命令:cnpm -v
结果:cnpm@7.6.0
【npm映射网址(镜像网址)】
命令:npm config get registry
结果:https://registry.npmjs.org/ (我这里是官方默认镜像)
【vue脚手架版本】
命令:vue -V
结果:
@vue/cli 5.0.8
2.安装版本
【安装指定版本的vue,需要卸载最新版本的vue】
npm uninstall -g @vue/cli
例如【安装指定的vue版本脚手架】
npm install -g @vue/cli@4.5.6
【安装指定的vue版本】
npm install vue@2.x.x
查看镜像源配置
1.查看当前使用的镜像地址:
npm config get registry
2.官方默认全局镜像
https://registry.npmjs.org
3.设置镜像源(淘宝镜像):
npm config set registry https://registry.npm.taobao.org
4.官方默认全局镜像
https://registry.npmjs.org
补充常用镜像源:
npm 官方原始镜像网址是:https://registry.npmjs.org/
淘宝 NPM 镜像:http://registry.npmmirror.com
阿里云 NPM 镜像:https://npm.aliyun.com
腾讯云 NPM 镜像:https://mirrors.cloud.tencent.com/npm/
华为云 NPM 镜像:https://mirrors.huaweicloud.com/repository/npm/
网易 NPM 镜像:https://mirrors.163.com/npm/
中国科学技术大学开源镜像站:http://mirrors.ustc.edu.cn/
清华大学开源镜像站:https://mirrors.tuna.tsinghua.edu.cn/
腾讯,华为,阿里的镜像站基本上比较全
建议用国内的镜像。