前端编译npm run build报错


目录
  • 1 错误描述
  • 2 解决过程

1 错误描述

执行 npm run build 报错
错误日志如下:

> tdf-ui-vue-tdfbase@2.3.7-SNAPSHOT build
> vue-cli-service build --mode production

sh: 1: vue-cli-service: not found

网上查找资料,说是没有安装vue-cli,或者没有安装好,需要删除node_modules/文件夹,然后重新执行 npm install 进行安装。
但是执行 npm install报错:

witt@work:~/1project/zzgzwbb/doc/北京升级部署文档/部署文件/前端源码/SCA-front$ npm install
npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR! 
npm ERR! While resolving: tdf-ui-vue-tdfbase@2.3.7-SNAPSHOT
npm ERR! Found: eslint@5.16.0
npm ERR! node_modules/eslint
npm ERR!   dev eslint@"^5.16.0" from the root project
npm ERR! 
npm ERR! Could not resolve dependency:
npm ERR! peer eslint@">=1.6.0 <5.0.0" from eslint-loader@2.0.0
npm ERR! node_modules/eslint-loader
npm ERR!   dev eslint-loader@"2.0.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 /home/witt/.npm/eresolve-report.txt for a full report.

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/witt/.npm/_logs/2022-03-02T09_24_14_632Z-debug.log

2 解决过程