<p>I would have a look at the <a href="https://wiki.jenkins.io/display/JENKINS/Tool+Auto-Installation" rel="nofollow noreferrer">Tool Auto-Installation</a> which allows Jenkins to install the tooling you need.</p>

<blockquote>
  <p>Lets you configure tools so that agents will install them on demand whenever running a job that needs them. This could be especially useful when running a large farm of agents in a cloud which all start with a minimal operating system configuration.</p>
</blockquote>

<p>Speaking of that also checkout the <a href="https://wiki.jenkins.io/display/JENKINS/NodeJS+Plugin" rel="nofollow noreferrer">NodeJS Plugin</a> which</p>

<blockquote>
  <p>Provides NodeJS auto-installer, allowing to create as many NodeJS installations "profiles" as you want.
  The auto-installer will automatically install a given version of NodeJS, on every jenkins slave where it will be needed
  Allows to install globally some npm packages inside each installations, these npm packages will be made available to the PATH</p>
</blockquote>

CC BY-SA 4.0
2019-10-09T10:05:09.243Z
2019-10-09T10:05:09.243Z
papanito
<p>I am in the middle of trying to implement a build/deploy job in Jenkins by which the latest version of source code is pulled from git, built and then deployed to GCP. So far I am able to retrieve the lastest code from GIT but have run into issues when tyring to build. The application being built/deployed is an Angular 7 web site using npm for package management. So the normal steps would be to run npm install to make sure the packages are installed and then ng build -- prod to build the app.</p>

<p>My issue is that the version of npm/nodejs in the master node is out of date and not compatable with Angular 7. Even just trying the command to gert the current ng version fails:</p>

<pre><code>+ /usr/bin/ng v
You are running version v8.1.4 of Node.js, which is not supported by Angular CLI v6.
The official Node.js version that is supported is 8.9 and greater.
</code></pre>

<p>I added a call to npm version to check the npm version is is trying to use:</p>

<pre><code>+ echo current user
current user
+ whoami
jenkins
+ npm -v
5.0.3
</code></pre>

<p>To investigate the issue I used putty to remote onto the jenkins box and ran npm -v and ng v to see what is installed and get:</p>

<pre><code>jenkins@****-int1:~$ npm -v
6.5.0-next.0
</code></pre>

<p>Which is different to that reported by npm -v in the shell script.</p>

<pre><code>jenkins@****:~$ ng v

     _                      _                 ____ _     ___
    / \   _ __   __ _ _   _| | __ _ _ __     / ___| |   |_ _|
   / △ \ | '_ \ / _` | | | | |/ _` | '__|   | |   | |    | |
  / ___ \| | | | (_| | |_| | | (_| | |      | |___| |___ | |
 /_/   \_\_| |_|\__, |\__,_|_|\__,_|_|       \____|_____|___|
                |___/


Angular CLI: 7.1.4
Node: 11.6.0
OS: linux x64
Angular:
...

Package                      Version
------------------------------------------------------
@angular-devkit/architect    0.11.4
@angular-devkit/core         7.1.4
@angular-devkit/schematics   7.1.4
@schematics/angular          7.1.4
@schematics/update           0.11.4
rxjs                         6.3.3
typescript                   3.1.6
</code></pre>

<p>So it should have nodejs 11.6, I ran node -v to double check:</p>

<pre><code>jenkins@****:~$ node -v
v11.6.0
</code></pre>

<p>BUT if I run nodejs -v I get:</p>

<pre><code>jenkins@****:~$ nodejs -v
v8.1.4
</code></pre>

<p>I thought that node and nodejs were the same thing? so why would I have two different versions installed and how to fix this?</p>

<p>To double check what my Jenkins script is using I added a call to node -v in the script and as expected it reports the older version:</p>

<pre><code>+ node -v
v8.1.4
</code></pre>

<p>I'm not a DevOps person, I'm C# back end developer who's been lumbered with sorting this out due staff changes. I know very little about Linux, Jenkins or this stuff in general.</p>

<p>I tried to update the node installation via the Jenkins Shell script using</p>

<pre><code>sudo npm cache clean -f
sudo npm install -g n
sudo n stable
</code></pre>

<p>But these were refused due to access rights (no sudo pwd I presume) and I don't know if that would've fixed the issue anyway.</p>

<p>Any help?</p>

CC BY-SA 4.0
2019-01-06T23:03:11.907Z
I think the difference in node versions you can see is because the node is installed to Jenkins host using 1.  Linux terminal and 2. node plugin in Jenkins. Maybe, try to update the Jenkins plugin for node or Angularjs.
Beware of making changes in the production server carefully.
KlwntSingh
<jenkins><node.js>
How to update nodejs on Jenkins master node?
JPT
# How to update nodejs on Jenkins master node?

(Asked by: username_0 on 2019-01-06)

I am in the middle of trying to implement a build/deploy job in Jenkins by which the latest version of source code is pulled from git, built and then deployed to GCP. So far I am able to retrieve the lastest code from GIT but have run into issues when tyring to build. The application being built/deployed is an Angular 7 web site using npm for package management. So the normal steps would be to run npm install to make sure the packages are installed and then ng build -- prod to build the app.
My issue is that the version of npm/nodejs in the master node is out of date and not compatable with Angular 7. Even just trying the command to gert the current ng version fails:
+ /usr/bin/ng v
You are running version v8.1.4 of Node.js, which is not supported by Angular CLI v6.
The official Node.js version that is supported is 8.9 and greater.

I added a call to npm version to check the npm version is is trying to use:
+ echo current user
current user
+ whoami
jenkins
+ npm -v
5.0.3

To investigate the issue I used putty to remote onto the jenkins box and ran npm -v and ng v to see what is installed and get:
jenkins@****-int1:~$ npm -v
6.5.0-next.0

Which is different to that reported by npm -v in the shell script.
jenkins@****:~$ ng v

     _                      _                 ____ _     ___
    / \   _ __   __ _ _   _| | __ _ _ __     / ___| |   |_ _|
   / △ \ | '_ \ / _` | | | | |/ _` | '__|   | |   | |    | |
  / ___ \| | | | (_| | |_| | | (_| | |      | |___| |___ | |
 /_/   \_\_| |_|\__, |\__,_|_|\__,_|_|       \____|_____|___|
                |___/


Angular CLI: 7.1.4
Node: 11.6.0
OS: linux x64
Angular:
...

Package                      Version
------------------------------------------------------
@angular-devkit/architect    0.11.4
@angular-devkit/core         7.1.4
@angular-devkit/schematics   7.1.4
@schematics/angular          7.1.4
@schematics/update           0.11.4
rxjs                         6.3.3
typescript                   3.1.6

So it should have nodejs 11.6, I ran node -v to double check:
jenkins@****:~$ node -v
v11.6.0

BUT if I run nodejs -v I get:
jenkins@****:~$ nodejs -v
v8.1.4

I thought that node and nodejs were the same thing? so why would I have two different versions installed and how to fix this?
To double check what my Jenkins script is using I added a call to node -v in the script and as expected it reports the older version:
+ node -v
v8.1.4

I'm not a DevOps person, I'm C# back end developer who's been lumbered with sorting this out due staff changes. I know very little about Linux, Jenkins or this stuff in general.
I tried to update the node installation via the Jenkins Shell script using
sudo npm cache clean -f
sudo npm install -g n
sudo n stable

But these were refused due to access rights (no sudo pwd I presume) and I don't know if that would've fixed the issue anyway.
Any help?

**Tags:** jenkins, node.js

> **Comments:**
> **username_1**: I think the difference in node versions you can see is because the node is installed to Jenkins host using 1.  Linux terminal and 2. node plugin in Jenkins. Maybe, try to update the Jenkins plugin for node or Angularjs. Beware of making changes in the production server carefully.  

---

## 1 answers

### Answer by username_2 on 2019-10-09. Score: 1 | Accepted answer

I would have a look at the [Tool Auto-Installation](https://wiki.jenkins.io/display/JENKINS/Tool+Auto-Installation) which allows Jenkins to install the tooling you need.

> Lets you configure tools so that agents will install them on demand whenever running a job that needs them. This could be especially useful when running a large farm of agents in a cloud which all start with a minimal operating system configuration.

Speaking of that also checkout the [NodeJS Plugin](https://wiki.jenkins.io/display/JENKINS/NodeJS+Plugin) which

> Provides NodeJS auto-installer, allowing to create as many NodeJS installations "profiles" as you want.
> The auto-installer will automatically install a given version of NodeJS, on every jenkins slave where it will be needed
> Allows to install globally some npm packages inside each installations, these npm packages will be made available to the PATH


---

