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框架整理

相关推荐
伍哥的传说1 小时前
鸿蒙系统(HarmonyOS)应用开发之手势锁屏密码锁(PatternLock)
前端·华为·前端框架·harmonyos·鸿蒙
yugi9878381 小时前
前端跨域问题解决Access to XMLHttpRequest at xxx from has been blocked by CORS policy
前端
浪裡遊2 小时前
Sass详解:功能特性、常用方法与最佳实践
开发语言·前端·javascript·css·vue.js·rust·sass
csdn_aspnet2 小时前
Node.js 使用 WebSockets 和 Socket.IO 实现实时聊天应用程序
node.js
旧曲重听12 小时前
最快实现的前端灰度方案
前端·程序人生·状态模式
默默coding的程序猿2 小时前
3.前端和后端参数不一致,后端接不到数据的解决方案
java·前端·spring·ssm·springboot·idea·springcloud
夏梦春蝉3 小时前
ES6从入门到精通:常用知识点
前端·javascript·es6
归于尽3 小时前
useEffect玩转React Hooks生命周期
前端·react.js
G等你下课3 小时前
React useEffect 详解与运用
前端·react.js
我想说一句3 小时前
当饼干遇上代码:一场HTTP与Cookie的奇幻漂流 🍪🌊
前端·javascript