vue2老版本 npm install 安装失败_安装卡主

vue2老版本 npm install 安装失败_安装卡主

特别说明:vue2老版本安装慢、运行慢,建议升级vue3+element plus+ vite

解决方案1:

第一步、修改npm 镜像为国内镜像

使用淘宝镜像:

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

清除缓存:

cs 复制代码
npm cache clean --force

查看镜像配置是否成功:

cs 复制代码
npm config set registry

第二步、升级 vue-core-js版本

"core-js": "^3.6.5" 升级版本直接修改版本号

javascript 复制代码
{
  "name": "back",
  "version": "0.1.0",
  "private": true,
  "scripts": {
    "serve": "set NODE_OPTIONS=--openssl-legacy-provider && vue-cli-service serve",
    "build": "set NODE_OPTIONS=--openssl-legacy-provider && vue-cli-service build",
    "lint": "vue-cli-service lint"
  },
  "dependencies": {
    "core-js": "^3.6.5",
    "element-ui": "^2.15.0",
    "vue": "^2.6.11",
    "vue-clipboard3": "^2.0.0",
    "vue-router": "^3.5.3",
    "vue-ueditor-wrap": "^2.4.4"
  },
  "devDependencies": {
    "@vue/cli-plugin-babel": "~4.5.0",
    "@vue/cli-plugin-eslint": "~4.5.0",
    "@vue/cli-plugin-router": "^4.5.11",
    "@vue/cli-service": "~4.5.0",
    "babel-eslint": "^10.1.0",
    "eslint": "^6.7.2",
    "eslint-plugin-vue": "^6.2.2",
    "vue-template-compiler": "^2.6.11"
  },
  "eslintConfig": {
    "root": true,
    "env": {
      "node": true,
      "browser": true,
      "jquery": true
    },
    "extends": [
      "plugin:vue/essential",
      "eslint:recommended"
    ],
    "parserOptions": {
      "parser": "babel-eslint"
    },
    "rules": {
      "no-console": "off",
      "no-unused-vars": "off",
      "no-undef": "off",
      "generator-star-spacing": "off",
      "no-tabs": "off",
      "no-irregular-whitespace": "off",
      "no-debugger": "off",
      "no-redeclare": "off",
      "no-inner-declarations": "off",
      "no-unused-labels": "off",
      "vue/no-unused-vars": "off",
      "vue/no-unused-components": "off"
    }
  },
  "browserslist": [
    "> 1%",
    "last 2 versions",
    "not dead"
  ]
}

删除文件 package-lock.json

第三步,重新执行安装命令

javascript 复制代码
npm  i

安装时间还是比较长,大约10分钟左右;

解决方案2:

还有一种方案,可以复制其他项目已经安装成功的 node_modules 文件夹,直接复制。

文件夹内容比较大 >100mb

更多:

Vue3.4+element-plus2.5 + Vite 搭建教程整理

Vite 下一代的前端工具链,前端开发与构建工具

基于Vue的移动端UI框架整理

相关推荐
VX:Fegn089540 分钟前
计算机毕业设计|基于springboot + vue校园社团管理系统(源码+数据库+文档)
前端·数据库·vue.js·spring boot·后端·课程设计
‿hhh1 小时前
综合交通运行协调与应急指挥平台项目说明
java·ajax·npm·json·需求分析·个人开发·规格说明书
ChangYan.1 小时前
直接下载源码但是执行npm run compile后报错
前端·npm·node.js
skywalk81632 小时前
在 FreeBSD 上可以使用的虚拟主机(Web‑Hosting)面板
前端·主机·webmin
ohyeah3 小时前
深入理解 React 中的 useRef:不只是获取 DOM 元素
前端·react.js
MoXinXueWEB3 小时前
前端页面获取不到url上参数值
前端
低保和光头哪个先来3 小时前
场景6:对浏览器内核的理解
开发语言·前端·javascript·vue.js·前端框架
想要一只奶牛猫3 小时前
Spring Web MVC(三)
前端·spring·mvc
奋飛3 小时前
微前端系列:核心概念、价值与应用场景
前端·微前端·micro·mfe·什么是微前端
cz追天之路4 小时前
华为机考 ------ 识别有效的IP地址和掩码并进行分类统计
javascript·华为·typescript·node.js·ecmascript·less·css3