Currently I have two versions of node installed on a Jenkins server.
$ n list
node/10.9.0
node/12.14.1
I'm trying to switch to version 10.9.0 for a specific build which requires it.
I've tried first by using n <version>
but the latest 12.14.1 still shows as active:
$ n 10.9.0
installed : v10.9.0 to /opt/jenkins/n/bin/node
active : v12.14.1 at /bin/node
I've also tried n use <version>
which just follows up with a prompt.
$ n use 10.9.0
>
I've read various articles on this but could not get any commands to effectively switch versions.
i.e. https://blog.logrocket.com/switching-between-node-versions-during-development/
Below is the n exectuable.
which n
/opt/jenkins/n/bin/n
Versions appear to get installed under the below directory:
/opt/jenkins/n/n/versions/node/
10.9.0
12.14.1
Below are the contents of /opt/jenkins/n/bin/
chrome-debug -> ../lib/node_modules/lighthouse/lighthouse-core/scripts/manual-chrome-launcher.js
lighthouse -> ../lib/node_modules/lighthouse/lighthouse-cli/index.js
n
ng
node
nodejs
npm -> ../lib/node_modules/npm/bin/npm-cli.js
npx -> ../lib/node_modules/npm/bin/npx-cli.js
n-uninstall
n-update
How can I switch node versions with n? Is there anything in the above that is missing? Thanks in advance.
/opt/jenkins/bin
– Maros/opt/jenkins/n/bin
. Only one nodejs is there. Interestingly the path shows/opt/jenkins/bin
which doesn't exist – Rheims/bin/node
points to/opt/jenkins/n/bin/nodejs
so after runningn <version>
this updates/opt/jenkins/n/bin/node
only. It needs to be copied to nodejscp /opt/jenkins/n/bin/node /opt/jenkins/n/bin/nodejs
and after that the correct node version is used. – Rheims