Npm: not found in jenkins pipeline

I am running Jenkins on Docker … I have one web application having backend Java and frontend some javascript. To automate the build process I need to build the javascript app from the front end. To do so I need npm to install bower, grunt etc.

But when I am trying to add sh “npm install”, it gives me npm:not found error. I have already enabled npm and nodejs plugin from plugin manager.

Is there a better way to do this ?

what image are you starting with?

I have pull jenkins:latest and then done configuration for jdk and maven and that seems working fine, I did the same for nodejs but that is not working

npm is not installed on that image… so you will have to do that 1st…

also, that image is deprecated, and you should use jenkins/jenkins:lts

jenkins/jenkins:lts uses apt-get to install new packages.

see the doc here

1 Like

Thank you , that worked like a champ