npm报错解决

npm install报错:peer

npm notice
npm notice New minor version of npm available! 7.19.1 -> 7.24.1
npm notice Changelog: https://github.com/npm/cli/releases/tag/v7.24.1
npm notice Run npm install -g [email protected] to update!
npm notice 
npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR! 
npm ERR! Found: [email protected]
npm ERR! node_modules/eslint
npm ERR!   dev eslint@"7.15.0" from the root project
npm ERR!   peer eslint@">= 1.6.0" from @vue/[email protected]  
npm ERR!   node_modules/@vue/cli-plugin-eslint
npm ERR!     dev @vue/cli-plugin-eslint@"4.4.6" from the root project
npm ERR!   2 more (babel-eslint, eslint-plugin-vue)
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer eslint@">=1.6.0 <7.0.0" from [email protected]
npm ERR! node_modules/@vue/cli-plugin-eslint/node_modules/eslint-loader
npm ERR!   eslint-loader@"^2.2.1" from @vue/[email protected]
npm ERR!   node_modules/@vue/cli-plugin-eslint
npm ERR!     dev @vue/cli-plugin-eslint@"4.4.6" 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 D:\softcache\node_cache\eresolve-report.txt for a full report.

npm ERR! A complete log of this run can be found in:
npm ERR!     D:\softcache\node_cache\_logs\2021-10-01T12_28_46_105Z-debug.log

开始一直纠结peer eslint@相关信息,未找到明确办法
偶然想到有提示Run npm install -g [email protected] to update!
想着先升个级吧,结果升级完问题解决

后来另一个项目仍旧提示类似错误

npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR! 
npm ERR! While resolving: [email protected]
npm ERR! Found: [email protected]
npm ERR! node_modules/html-webpack-plugin
npm ERR!   dev html-webpack-plugin@"4.0.0-alpha" from the root project
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer html-webpack-plugin@"^3.0.0" from [email protected]
npm ERR! node_modules/script-ext-html-webpack-plugin
npm ERR!   dev script-ext-html-webpack-plugin@"2.0.1" 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 D:\softcache\node_cache\eresolve-report.txt for a full report.

再看提示使用:
–force 会无视冲突,并强制获取远端npm库资源,即使本地有资源也会覆盖掉
–legacy-peer-deps:安装时忽略所有peerDependencies,忽视依赖冲突,采用npm版本4到版本6的样式去安装依赖,已有的依赖不会覆盖
采用提示的第二种方式解决

npm install报错:Parsing error

报错各种Parsing error:

Module Warning (from ./node_modules/eslint-loader/index.js):
error: Parsing error: The keyword 'const' is reserved at src\router\order.js:1:1:
> 1 | const Tabbar = () => import('@/components/Tabbar/');
    | ^
  2 |
  3 | export default [
  4 |   {
……
Module Warning (from ./node_modules/eslint-loader/index.js):
error: Parsing error: Unexpected token < at src\views\user\tabbar-user-header.vue:1:1:
> 1 | <template>
    | ^
  2 |   <div class="user_header" :style="{backgroundImage: `url(${background_image})`}">
  3 |     <van-icon name="set" class="user_set" @click="toSetting"/>
  4 |     <div class="user_avatar">

尝试1:失败

开发环境与ESLint当前的解析功能不兼容,安装:
npm install babel-eslint --save-dev
.eslintrc中添加"parser": “babel-eslint”

尝试2:解决

.eslintrc修改
parserOptions: {
sourceType: ‘module’
},
parser: “vue-eslint-parser”,
env: {
browser: true,
node: true,
es6: true,
},

Guess you like

Origin blog.csdn.net/machao0_0/article/details/120581557