安装依赖时报错:npm ERR! code ERESOLVE npm ERR! ERESOLVE could not resolve npm ERR! npm ERR! While resolving

[~/Desktop/Code/xxx/xxx]$ npm install
npm ERR! code ERESOLVE
npm ERR! ERESOLVE could not resolve
npm ERR! 
npm ERR! While resolving: [email protected]
npm ERR! Found: [email protected]
npm ERR! node_modules/webpack
npm ERR!   peer webpack@"^4.0.0" from @intervolga/[email protected]
npm ERR!   node_modules/@intervolga/optimize-cssnano-plugin
npm ERR!     @intervolga/optimize-cssnano-plugin@"^1.0.5" from @vue/[email protected]
npm ERR!     node_modules/@vue/cli-service
npm ERR!       dev @vue/cli-service@"~4.4.0" from the root project
npm ERR!       4 more (@vue/cli-plugin-babel, @vue/cli-plugin-eslint, ...)
npm ERR!   peer webpack@"^4.0.0 || ^5.0.0" from @soda/[email protected]
npm ERR!   node_modules/@soda/friendly-errors-webpack-plugin
npm ERR!     @soda/friendly-errors-webpack-plugin@"^1.7.1" from @vue/[email protected]
npm ERR!     node_modules/@vue/cli-service
npm ERR!       dev @vue/cli-service@"~4.4.0" from the root project
npm ERR!       4 more (@vue/cli-plugin-babel, @vue/cli-plugin-eslint, ...)
npm ERR!   22 more (@vue/cli-plugin-babel, @vue/cli-plugin-eslint, ...)
npm ERR! 
npm ERR! Could not resolve dependency:
npm ERR! peer webpack@"^2.0.0 || ^3.0.0" from [email protected]
npm ERR! node_modules/uglifyjs-webpack-plugin
npm ERR!   dev uglifyjs-webpack-plugin@"^1.1.0" from the root project
npm ERR! 
npm ERR! Conflicting peer dependency: [email protected]
npm ERR! node_modules/webpack
npm ERR!   peer webpack@"^2.0.0 || ^3.0.0" from [email protected]
npm ERR!   node_modules/uglifyjs-webpack-plugin
npm ERR!     dev uglifyjs-webpack-plugin@"^1.1.0" 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! See /Users/effy/.npm/eresolve-report.txt for a full report.

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/effy/.npm/_logs/2023-06-26T11_28_37_107Z-debug-0.log

输入如下代码,即可安装成功。

npm i axios -S --legacy-peer-deps 

安装依赖时报错:npm ERR! code ERESOLVE npm ERR! ERESOLVE could not resolve npm ERR! npm ERR! While resolving_第1张图片

npm run serve报错

[~/Desktop/Code/xxx/xxx]$ npm run serve  

> [email protected] serve
> vue-cli-service serve

 INFO  Starting development server...
10% building 4/5 modules 1 active .../Code/xxx/xxx/node_modules/cache-loader/dist/cjs.js??ref--12-0!/Users/effy/Desktop/Code/xxx/xxx/node_modules/babel-loader/lib/index.js!/Users/effy/Desktop/Code/xxx/xxx/src/main.jsBrowserslist: caniuse-lite is outdated. Please run:
  npx update-browserslist-db@latest
  Why you should do it regularly: https://github.com/browserslist/update-db#readme
98% after emitting SizeLimitsPlugin

 ERROR  Failed to compile with 1 error                                                                                                                                                                                                               19:29:58

 error  in ./src/styles/base.scss

Syntax Error: Error: Node Sass does not yet support your current environment: OS X 64-bit with Unsupported runtime (93)
For more information on which environments are supported please see:
https://github.com/sass/node-sass/releases/tag/v4.14.1


 @ ./src/styles/base.scss 4:14-224 14:3-18:5 15:22-232
 @ ./src/main.js
 @ multi (webpack)-dev-server/client?http://localhost:8080&sockPath=/sockjs-node (webpack)/hot/dev-server.js ./src/main.js

原因是node版本太高,降低版本即可

# 安装node12.6.0版本
nvm install 12.6.0
# 设置默认版本为12.6.0 
nvm alias default 12.6.0 
# 查看node版本
node -v

然后npm install即可,笔者习惯用yarn,它更快一点

安装依赖时报错:npm ERR! code ERESOLVE npm ERR! ERESOLVE could not resolve npm ERR! npm ERR! While resolving_第2张图片

你可能感兴趣的:(npm,vue.js,javascript)