• 最新 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
    
    • 1
    node_global
    
    • 1

    在这里插入图片描述

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

    在这里插入图片描述

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

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

    切换镜像

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

    检查镜像

    npm config get registry
    
    • 1

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

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

    出现

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

    npm install -g npm@10.5.0
    
    • 1

    继续安装

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

    在这里插入图片描述

    出现问题

    在这里插入图片描述

    解决方法

    在这里插入图片描述
    1、将 node_global 文件夹中的 cnpm、cnpm.cmd、cnpm.ps1 移动到 Node 根目录

    在这里插入图片描述
    2、将 node_global 文件下的node_modules 文件下的 cnpm 移动到根目录的node_modules目录里面

    在这里插入图片描述

    测试是否成功

    cnpm -v
    
    • 1
    npm -v
    
    • 1

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

    • 都没问题,解决。
  • 相关阅读:
    c#事件(event)
    中文核心期刊有哪些?
    [附源码]Python计算机毕业设计Django体育器材及场地管理系统
    Bean的加载方式
    MetaTown:一个可以自己构建数字资产的平台
    浅谈与 DBA 息息相关的 Database Plus 理念
    Android总结
    2024/4/3 IOday5
    C++ 通过CreateProcess函数和ShellExecute函数打开另一个exe
    Java开发模拟面试记录
  • 原文地址:https://blog.csdn.net/weixin_56050344/article/details/136431068