DEV Community

Cover image for How To Install NPM and Node.js in Jenkins
Tomislav Kraljic
Tomislav Kraljic

Posted on

How To Install NPM and Node.js in Jenkins

This article will be a continuation of my previous article (Configuring and Running Jenkins on a Remote Server with Docker).

If you haven't read it, here is the link:
https://dev.to/tomislavkraljic/configuring-and-running-jenkins-on-a-remote-server-with-docker-1cdl

In that tutorial, I went over how to create a remote server on Digital Ocean, configuring, and run Jenkins in a Docker Container on that server.

In this article, I will be teaching you how to install npm and Node.js inside a Jenkins Container. Let's get started!


Step 1: Make sure you remote server is up and running.

Step 2: SSH into your remote server via the command line.

 ssh root@<ipv4_address>
Enter fullscreen mode Exit fullscreen mode

Step 3: Grab the container id of Jenkins:

docker ps
Enter fullscreen mode Exit fullscreen mode

Step 4: Enter inside the container that is running Jenkins as root user

docker exec -u 0 -it <container_id> bash
Enter fullscreen mode Exit fullscreen mode

Step 5: Check Linux Distribution running in your Container

cat /etc/issue
Enter fullscreen mode Exit fullscreen mode

Step 6: Update APT

apt-update
Enter fullscreen mode Exit fullscreen mode

Step 7: If not already, install Curl

apt install curl
Enter fullscreen mode Exit fullscreen mode

Step 8: Run curl command to get scripts to install Node.js and NPM

curl -sL https://deb.nodesource.com/setup_14.x -o nodesource_setup.sh
Enter fullscreen mode Exit fullscreen mode

Step 9: Execute script

bash nodesource_setup.sh
Enter fullscreen mode Exit fullscreen mode

Step 10: Install Node.js and NPM

apt install nodejs
Enter fullscreen mode Exit fullscreen mode

Congratulations! You successfully installed NPM and Node.js for Jenkins!

Discussion (0)