npm install 报错

npm install 报错

npm install 报错

java 复制代码
npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR!
npm ERR! While resolving: yudao-ui-admin@1.8.0-snapshot
npm ERR! Found: eslint@7.15.0
npm ERR! node_modules/eslint
npm ERR!   dev eslint@"7.15.0" from the root project
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer eslint@">= 1.6.0 < 7.0.0" from @vue/cli-plugin-eslint@4.5.18
npm ERR! node_modules/@vue/cli-plugin-eslint
npm ERR!   dev @vue/cli-plugin-eslint@"4.5.18" from the root project
npm ERR!
npm ERR! Fix the upstream dependency conflict, or retry
npm ERR! this command with --force or --legacy-peer-deps
npm ERR! to accept an incorrect (and potentially broken) dependency resolution.
npm ERR!
npm ERR!
npm ERR! For a full report see:
npm ERR! C:\Users\HX\AppData\Local\npm-cache\_logs\2023-08-30T14_59_25_161Z-eresolve-report.txt

npm ERR! A complete log of this run can be found in: C:\Users\HX\AppData\Local\npm-cache\_logs\2023-08-30T14_59_25_161Z-debug-0.log

D:\WorkSpace\ruoyi-vue-pro\yudao-ui-admin>npm cache clear --forc
npm WARN using --force Recommended protections disabled.

解决方案:

npm install --legacy-peer-deps

不支持nodejs 18 报错

java 复制代码
npm WARN EBADENGINE Unsupported engine {
npm WARN EBADENGINE   package: '@achrinza/node-ipc@9.2.2',
npm WARN EBADENGINE   required: { node: '8 || 10 || 12 || 14 || 16 || 17' },
npm WARN EBADENGINE   current: { node: 'v18.17.1', npm: '9.6.7' }
npm WARN EBADENGINE }
npm WARN EBADENGINE Unsupported engine {
npm WARN EBADENGINE   package: 'pkcs7@0.2.3',
npm WARN EBADENGINE   required: { npm: '^1.4.6', node: '^0.10' },
npm WARN EBADENGINE   current: { node: 'v18.17.1', npm: '9.6.7' }
npm WARN EBADENGINE }

解决方案:

在package-lock.json文件中修改

java 复制代码
      "engines": {
        "node": "8 || 10 || 12 || 14 || 16 || 17 || 18"
      }

在package.json可能需要添加属性 .

SET NODE_OPTIONS=--openssl-legacy-provider

java 复制代码
  "scripts": {
    "local": "SET NODE_OPTIONS=--openssl-legacy-provider &&  vue-cli-service serve --mode local",
    "dev": "SET NODE_OPTIONS=--openssl-legacy-provider && vue-cli-service serve --mode dev",
    "front": "vue-cli-service serve --mode front",
    "build:prod": "SET NODE_OPTIONS=--openssl-legacy-provider && vue-cli-service build --mode prod",
    "build:stage": "vue-cli-service build --mode stage",
    "build:dev": "SET NODE_OPTIONS=--openssl-legacy-provider && vue-cli-service build --mode dev",
    "build:static": "vue-cli-service build --mode static",
    "preview": "node build/index.js --preview",
    "lint": "eslint --ext .js,.vue src",
    "clean": "rimraf node_modules"
  },

直接启动

npm run dev

java 复制代码
> yudao-ui-admin@1.8.0-snapshot dev
> SET NODE_OPTIONS=--openssl-legacy-provider && vue-cli-service serve --mode dev

Browserslist: caniuse-lite is outdated. Please run:
  npx update-browserslist-db@latest
  Why you should do it regularly: https://github.com/browserslist/update-db#readme
 INFO  Starting development server...
98% after emitting CopyPlugin

 DONE  Compiled successfully in 29648ms                                                                                                                                                                                       23:20:59

  App running at:
  - Local:   http://localhost:81/
  - Network: http://192.168.1.102:81/
相关推荐
前端白袍1 小时前
Nuxt:利用public-ip这个npm包来获取公网IP
网络协议·tcp/ip·npm
微臣愚钝2 小时前
前端【8】HTML+CSS+javascript实战项目----实现一个简单的待办事项列表 (To-Do List)
前端·javascript·css·html
lilu88888883 小时前
AI代码生成器赋能房地产:ScriptEcho如何革新VR/AR房产浏览体验
前端·人工智能·ar·vr
LCG元3 小时前
Vue.js组件开发-实现对视频预览
前端·vue.js·音视频
阿芯爱编程3 小时前
vue3 react区别
前端·react.js·前端框架
烛.照1034 小时前
Nginx部署的前端项目刷新404问题
运维·前端·nginx
YoloMari4 小时前
组件中的emit
前端·javascript·vue.js·微信小程序·uni-app
浪浪山小白兔4 小时前
HTML5 Web Worker 的使用与实践
前端·html·html5
疯狂小料5 小时前
React 路由导航与传参详解
前端·react.js·前端框架
追光少年33226 小时前
Learning Vue 读书笔记 Chapter 2
前端·javascript·vue.js·vue3