记一次npm run build:prod打包失败的处理方法

报错日志:

0 info it worked if it ends with ok
1 verbose cli [
1 verbose cli   '/var/jenkins_home/tools/jenkins.plugins.nodejs.tools.NodeJSInstallation/NodeJS14.15.5/bin/node',
1 verbose cli   '/var/jenkins_home/tools/jenkins.plugins.nodejs.tools.NodeJSInstallation/NodeJS14.15.5/bin/npm',
1 verbose cli   'run',
1 verbose cli   'build:prod'
1 verbose cli ]
2 info using [email protected]
3 info using [email protected]
4 verbose run-script [ 'prebuild:prod', 'build:prod', 'postbuild:prod' ]
5 info lifecycle [email protected]~prebuild:prod: [email protected]
6 info lifecycle [email protected]~build:prod: [email protected]
7 verbose lifecycle [email protected]~build:prod: unsafe-perm in lifecycle true
8 verbose lifecycle [email protected]~build:prod: PATH: /var/jenkins_home/tools/jenkins.plugins.nodejs.tools.NodeJSInstallation/NodeJS14.15.5/lib/node_modules/npm/node_modules/npm-lifecycle/node-gyp-bin:/var/jenkins_home/workspace/00-front-platform/node_modules/.bin:/var/jenkins_home/jdk-11.0.10+9/bin:/var/jenkins_home/tools/jenkins.plugins.nodejs.tools.NodeJSInstallation/NodeJS14.15.5/bin:/opt/java/openjdk/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
9 verbose lifecycle [email protected]~build:prod: CWD: /var/jenkins_home/workspace/00-front-platform
10 silly lifecycle [email protected]~build:prod: Args: [ '-c', 'vue-cli-service build' ]
11 silly lifecycle [email protected]~build:prod: Returned: code: 1  signal: null
12 info lifecycle [email protected]~build:prod: Failed to exec build:prod script
13 verbose stack Error: [email protected] build:prod: `vue-cli-service build`
13 verbose stack Exit status 1
13 verbose stack     at EventEmitter. (/var/jenkins_home/tools/jenkins.plugins.nodejs.tools.NodeJSInstallation/NodeJS14.15.5/lib/node_modules/npm/node_modules/npm-lifecycle/index.js:332:16)
13 verbose stack     at EventEmitter.emit (events.js:315:20)
13 verbose stack     at ChildProcess. (/var/jenkins_home/tools/jenkins.plugins.nodejs.tools.NodeJSInstallation/NodeJS14.15.5/lib/node_modules/npm/node_modules/npm-lifecycle/lib/spawn.js:55:14)
13 verbose stack     at ChildProcess.emit (events.js:315:20)
13 verbose stack     at maybeClose (internal/child_process.js:1048:16)
13 verbose stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:288:5)
14 verbose pkgid [email protected]
15 verbose cwd /var/jenkins_home/workspace/00-front-platform
16 verbose Linux 3.10.0-1160.25.1.el7.x86_64
17 verbose argv "/var/jenkins_home/tools/jenkins.plugins.nodejs.tools.NodeJSInstallation/NodeJS14.15.5/bin/node" "/var/jenkins_home/tools/jenkins.plugins.nodejs.tools.NodeJSInstallation/NodeJS14.15.5/bin/npm" "run" "build:prod"
18 verbose node v14.15.5
19 verbose npm  v6.14.11
20 error code ELIFECYCLE
21 error errno 1
22 error [email protected] build:prod: `vue-cli-service build`
22 error Exit status 1
23 error Failed at the [email protected] build:prod script.
23 error This is probably not a problem with npm. There is likely additional logging output above.
24 verbose exit [ 1, true ]

处理方法:

#(1)第一步
npm cache clean --force
 
#(2)第二步 删除node_modules文件夹
linux上:rm -rf node_modules
window上: 直接手动删除
 
#(3)如果有package-lock.json文件就删除它,没有不用管,直接跳到第(4)步
linux上:rm -rf package-lock.json
window上: 直接手动删除
 
#(4)安装模块
npm install

 

你可能感兴趣的:(CentOS,编程,vue,npm,vue-cli3,前端,nodejs)