Angular-正在获取sh:ng:在Jenkins中运行“ npm run ng build”时找不到命令

问题描述

我正在尝试在詹金斯建立一个有角度的项目

都尝试了

"build": "npm run ng build",

以及

"build": "ng build"

,但出现相同的错误。可能是因为在jenkins中设置了该项目的方式吗?

在我的本地计算机上进行设置

“构建”:“ npm run ng build”

工作正常。但是在詹金斯身上失败了。

Jenkins的日志如下-

12:54:27 > ******* build /home/jenkins/workspace/********
12:54:27 > npm run ng build
12:54:27 
12:54:27 
12:54:27 > ******* ng /home/jenkins/workspace/**********
12:54:27 > ng "build"
12:54:27 
12:54:27 sh: ng: command not found
12:54:27 npm ERR! code ELIFECYCLE
12:54:27 npm ERR! syscall spawn
12:54:27 npm ERR! file sh
12:54:27 npm ERR! errno ENOENT
12:54:27 npm ERR! ******* ng: `ng "build"`
12:54:27 npm ERR! spawn ENOENT
12:54:27 npm ERR! 
12:54:27 npm ERR! Failed at the ******** ng script.
12:54:27 npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
12:54:27 npm WARN Local package.json exists,but node_modules missing,did you mean to install?
12:54:27 
12:54:27 npm ERR! A complete log of this run can be found in:
12:54:27 npm ERR!     /home/jenkins/.npm/_logs/2020-09-09T18_54_22_494Z-debug.log
12:54:27 npm ERR! code ELIFECYCLE
12:54:27 npm ERR! errno 1
12:54:27 npm ERR! ******* build: `npm run ng build`
12:54:27 npm ERR! Exit status 1
12:54:27 npm ERR! 
12:54:27 npm ERR! Failed at the ******** build script.
12:54:27 npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
12:54:27 npm WARN Local package.json exists,did you mean to install?
12:54:27 
12:54:27 npm ERR! A complete log of this run can be found in:
12:54:27 npm ERR!     /home/jenkins/.npm/_logs/2020-09-09T18_54_22_527Z-debug.log
12:54:27 /tmp/jenkins4346657790254352101.sh: line 12: cd: 
/var/lib/jenkins/workspace/********/dist: No such file or directory
12:54:27 cp: cannot stat 
‘/var/lib/jenkins/workspace/******/dist/********’: No such file or directory
12:54:27 Build step 'Execute shell' marked build as failure
12:54:27 New run name is 'CZ BLD# 254796'
12:54:27 Notifying upstream projects of job completion
12:54:27 Finished: FAILURE

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)