最新 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 根目录新建文件夹
node_cache
node_global

在这里插入图片描述

  • 配置路径
npm config set prefix "你的 node_global 文件夹"
npm config set cache "你的 node_cache 文件夹"

在这里插入图片描述

  • 新增环境变量
    在这里插入图片描述
  • 更换镜像

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

切换镜像

npm config set registry https://registry.npmmirror.com

检查镜像

npm config get registry

在这里插入图片描述
测试npm,安装cnpm淘宝镜像

npm install -g cnpm --registry=https://registry.npmmirror.com

出现

在这里插入图片描述
更新 npm 版本

npm install -g npm@10.5.0

继续安装

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目录里面

在这里插入图片描述

测试是否成功

cnpm -v
npm -v

在这里插入图片描述
在这里插入图片描述

  • 都没问题,解决。
  • 29
    点赞
  • 19
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 2
    评论
vue项目准备: 1、安装nodejs,官网下载傻瓜安装 node -v 验证 2、npm包管理器,是集成在node中的,所以安装了node也就有了npm npm -v 验证 3、安装cnpm npm install -g cnpm --registry=http://registry.npm.taobao.org (完成之后,我们就可以用cnpm代替npm来安装依赖包了。如果想进一步了解cnpm的,查看淘宝npm镜像官网。) 4、安装vue-cli脚手架构建工具 npm install -g vue-cli vue项目构建: 1、初始化项目模板: vue init webpack-simple yunshi-approve 或者 vue init webpack yunshi-approve 2、安装npm cd yunshi-approve 3、安装项目所需要的依赖: npm install 或 cnpm install 4、运行看效果: npm run dev 介绍一下目录及其作用: build:最终发布的代码的存放位置。 config:配置路径、端口号等一些信息,我们刚开始学习的时候选择默认配置node_modules:npm 加载的项目依赖模块。 src:这里是我们开发的主要目录,基本上要做的事情都在这个目录里面,里面包含了几个目录及文件: assets:放置一些图片,如logo等 components:目录里放的是一个组件文件,可以不用。 App.vue项目入口文件,我们也可以将组件写这里,而不使用components目录。 main.js :项目的核心文件 static:静态资源目录,如图片、字体等。 test:初始测试目录,可删除 .XXXX文件:配置文件。 index.html:首页入口文件,可以添加一些meta信息或者同统计代码啥的。 package.json:项目配置文件。 README.md:项目的说明文件。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

她似晚风般温柔789

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值