yarn install报依赖版本错误怎么解决呢?

vue2工程使用yarn install --foce安装node_modules依赖报以下错咋整呢?
npm i也不好使,会报个其他错

说js-beautify依赖node版本不对,但是本机只能用node 12.20.0版本的

package.json文件指定js-beautify版本也不好使,求大佬们帮帮忙

"dependencies": {
    "animate.css": "^4.1.1",
    "axios": "0.18.0",
    "clipboard": "2.0.4",
    "codemirror": "5.45.0",
    "driver.js": "0.9.5",
    "dropzone": "5.5.1",
    "echarts": "5.1.2",
    "element-ui": "2.13.2",
    "file-saver": "2.0.1",
    "font-awesome": "^4.7.0",
    "fuse.js": "3.4.4",
    "iscroll": "^5.2.0",
    "js-cookie": "2.2.0",
    "js-md5": "^0.7.3",
    "jsonlint": "1.6.3",
    "jszip": "3.2.1",
    "lodash": "^4.17.15",
    "normalize.css": "7.0.0",
    "nprogress": "0.2.0",
    "path-to-regexp": "2.4.0",
    "screenfull": "4.2.0",
    "showdown": "1.9.0",
    "sortablejs": "1.8.4",
    "vue": "2.6.10",
    "vue-count-to": "1.0.13",
    "vue-photo-preview": "^1.1.3",
    "vue-router": "3.0.2",
    "vue-seamless-scroll": "^1.1.23",
    "vue-splitpane": "1.0.4",
    "vue-virtual-scroll-list": "^2.3.5",
    "vuedraggable": "2.20.0",
    "vuex": "3.1.0",
    "wavesurfer.js": "^5.2.0",
    "xlsx": "0.14.1"
  },
  "devDependencies": {
    "@babel/core": "7.0.0",
    "@babel/register": "7.0.0",
    "@vue/cli-plugin-babel": "3.5.3",
    "@vue/cli-plugin-eslint": "3.5.1",
    "@vue/cli-plugin-unit-jest": "3.5.3",
    "@vue/cli-service": "3.5.3",
    "@vue/test-utils": "1.0.0-beta.29",
    "autoprefixer": "^9.5.1",
    "babel-core": "7.0.0-bridge.0",
    "babel-eslint": "8.2.1",
    "babel-jest": "23.6.0",
    "chalk": "2.4.2",
    "chokidar": "2.1.5",
    "connect": "3.6.6",
    "js-beautify": "1.14.2",
    "eslint": "5.15.3",
    "eslint-plugin-vue": "5.2.2",
    "html-webpack-plugin": "3.2.0",
    "husky": "1.3.1",
    "lint-staged": "8.1.5",
    "mockjs": "1.0.1-beta3",
    "node-sass": "^4.9.0",
    "plop": "2.3.0",
    "runjs": "^4.3.2",
    "sass-loader": "^7.1.0",
    "sass-resources-loader": "^2.2.1",
    "script-ext-html-webpack-plugin": "2.1.3",
    "script-loader": "0.7.2",
    "serve-static": "^1.13.2",
    "svg-sprite-loader": "4.1.3",
    "svgo": "1.2.0",
    "terser-webpack-plugin": "^1.2.3",
    "vue-template-compiler": "2.6.10"
  },
阅读 1.4k
2 个回答
✓ 已被采纳

nodejs 版本问题,包 js-beautify@1.15.1 需要nodejs 14+,你项目当前的nodejs版本是12.12.0:
解决方法:

  1. 可以尝试将devDependencies和devDependencies中版本号前面^~移除试试
  2. 升级 nodejs 版本

package.json 里面的依赖版本中的 ~^ 符号全部去掉,都设置为固定的版本号之后 yarn cache clean 清一下缓存,删除 node_modules 目录重新 yarn 安装依赖。

看上面的异常输出是 js-beautify1.15.1 需求的 nodejs 版本比较高,使用 1.14.2 应该就没问题了。我这边 add 是不会有 ERROR 抛出的,会有一些 WARNING 但是问题不大。

不知道你固定版本之后的 不好使 指的是什么。固定版本应该是不会有 ERROR 抛出的

推荐问题
宣传栏