简体   繁体   中英

Jenkins cannot run npm or pm2 by itself

So I have a Jenkins CI setup on an EC2 server. I have nodejs and npm installed. Weirdly, Jenkins can access them via the command line if I do something like:

sudo -u jenkins node -v

However, Jenkins cannot access them inside an actual build runtime, and I get the following errors:

npm: command not found
pm2: command not found

npm is definitely installed, and ec2-user/root users can access it. What PATH do I have to change so that Jenkins can access it too?

I think that if you use the nodejs plugin it will be easier to manage your node and npm in this box. Also, this plugin allows installing some global modules that possibly you will need to build your project:

https://wiki.jenkins-ci.org/display/JENKINS/NodeJS+Plugin

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM