最新 Node 初始化 vue 项目报错(npm init vue@latest)以及配置淘宝镜像(cnpm)

最新 Node 初始化 vue 项目报错(npm init vue@latest)以及配置淘宝镜像(cnpm)

PS E:\SpringBootBase\ProjectOne\big-event-vue> cnpm init vue@latest

cnpm : The term 'cnpm' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the

path is correct and try again.

At line:1 char:1

  • cnpm init vue@latest

  • ~~~~

  • CategoryInfo : ObjectNotFound: (cnpm:String) [], CommandNotFoundException

  • FullyQualifiedErrorId : CommandNotFoundException

PS E:\SpringBootBase\ProjectOne\big-event-vue> npm init vue@latest

npm ERR! code CERT_HAS_EXPIRED

npm ERR! errno CERT_HAS_EXPIRED

npm ERR! request to https://registry.npm.taobao.org/create-vue failed, reason: certificate has expired

npm ERR! A complete log of this run can be found in: F:\IDEACODE\node\node_modules_logs\2024-03-03T06_01_11_297Z-debug-0.log

PS E:\SpringBootBase\ProjectOne\big-event-vue>

解决方法

  • 1、node 根目录新建文件夹
java 复制代码
node_cache
java 复制代码
node_global
  • 配置路径
java 复制代码
npm config set prefix "你的 node_global 文件夹"
java 复制代码
npm config set cache "你的 node_cache 文件夹"
  • 新增环境变量
  • 更换镜像

npm淘宝镜像的设置(2024.2.2:因为1 月 22 日,淘宝原镜像域名(registry.npm.taobao.org)的 HTTPS证书正式到期。如果想要继续使用,需要将 npm 源切换到新的源(registry.npmmirror.com),否则会报错。

切换镜像

java 复制代码
npm config set registry https://registry.npmmirror.com

检查镜像

java 复制代码
npm config get registry

测试npm,安装cnpm淘宝镜像

java 复制代码
npm install -g cnpm --registry=https://registry.npmmirror.com

出现

更新 npm 版本

java 复制代码
npm install -g npm@10.5.0

继续安装

java 复制代码
npm install -g cnpm --registry=https://registry.npmmirror.com

出现问题

解决方法

1、将 node_global 文件夹中的 cnpm、cnpm.cmd、cnpm.ps1 移动到 Node 根目录

2、将 node_global 文件下的node_modules 文件下的 cnpm 移动到根目录的node_modules目录里面

测试是否成功

java 复制代码
cnpm -v
java 复制代码
npm -v


  • 都没问题,解决。
相关推荐
_xaboy3 小时前
FormCreate 设计器 v6.3 正式发布:AI 表单助理3.0登场!
前端·vue.js·低代码·开源·表单设计器
马玉霞3 小时前
vue web端页面组件展示
前端·vue.js
代码煮茶3 小时前
Vue3 权限系统实战 | 从 0 搭建完整 RBAC 权限管理
前端·javascript·vue.js
阳火锅4 小时前
💡 告别类名地狱!Tailwind CSS 语义化转换神器来了
前端·css·vue.js
用户125758524364 小时前
XYGo Admin 即时通讯与异步任务实战:WebSocket 长连接 + 消息队列驱动后台处理
vue.js
PBitW5 小时前
组件封装注意事项
前端·vue.js
城数派5 小时前
1958-2024年乡镇的逐月土壤湿度数据
数据库·arcgis·数据分析·excel
i220818 Faiz Ul6 小时前
高校教务|教务管理|基于springboot+vue的高校教务管理系统(源码+数据库+文档)
java·数据库·vue.js·spring boot·论文·毕设·高校教务系统
非科班Java出身GISer6 小时前
ArcGIS JS 基础教程(6):地图弹窗信息窗口
arcgis·arcgis js信息框·arcgis js 弹出框·arcgis js popup·arcgis js 弹出信息
漂移的电子6 小时前
【el-tree】外层多选,某个属性内层单选
前端·javascript·vue.js