How can I choose node version for ng build command? - node.js

I have two different version of node version installed - 11.6 and 13.6. 13.6v is set in path variable so that is default node. I have a project which needs to be built only using 11.6v. But my ng command is using node 13.6 by default (I checked this using ng --version). Is there anyway I can ask ng to use node from a specific folder where I have 11.6 installed instead of the default one.
Edit: This is on Jenkins VM, so I don't have much access to change things.

I think the easiest way to work with different versions is using nvm tool.
See:
https://github.com/nvm-sh/nvm

Related

Set node version differently for specific project(folder) via NVM

I know I can change the node version by nvm use CLI command. However, I want to set specific node version differently for a certain project(folder). It's changed via nvm use command but it's reverted to default version whenever I restart the terminal or webstorm IDE.
How can I set nvm remember this different version for a certain project(folder)?
You can use an .nvmrc file in the root of the project with the version you want to use. For example v12.4.0 or v10.16.0.
You have to make sure that this version is installed or it will use the default node version in your machine.
For example, you want your default node version for this project to be v12.
Open your command line in the project root folder, then run nvm use 12, then run node -v > .nvmrc.
It won't solve your issue completely because you'll anyway have to run nvm use just without the version.

How to use different versions of Node simultaneously using NVM

Steps we have tried :-
1) We installed nvm and its node version in our CI server.
2) There are two projects. Both use different versions of node.
3) When we run 'nvm use version' . Same node version is set for both the projects. Due to this simultaneous build is not working.
Is it possible to use different versions of node simultaneously.
Works for Linux. You can see I have two versions of node is installed in my machine
-> v10.15.3
v12.10.0
Then I ran
`nvm alias default node`.
In the current cli my node version is 10.15.3.
Now open another cli window and check that. For me that is is 12.10.0.
So set a default version then change around it using
nvm use your_desired_version
. See below image.

Angular - How can I specify a different node.js version than what is installed on the system?

System: CENTOS7
I'm working on our TEST system that has a version of node prior to 8.9.
The application which I'm working on uses node 8.9.
The application runs fine when deployed out to Tomcat.
The issue is that I'm unable to just run 'ng serve' because the system sees v6.x.x.
Is there a way that I can modify my project to see the packaged node v8.x so I can run the ng options?
I'm instructed to not modify the system settings.
UPDATE
Just so others know what I ended up doing was modifying my bash script to include in the PATH ./node_modules to where node was in the local project. This is always the same path for whatever project and its version on node.
I did that for a while until a few months ago when we finally had rights to do things differently and are now using Node Version Manager
Install nvm (node version manager) to centOS
Then you will can install many version of node in your system
In this case you have to alias default version of node in nvm setting with version you want

Can I run multiple node version on Jenkins?

Currently I met one problem about Jenkins.
The ex-projects are using Angular 4 with node version 8.
The new project is using Angular 8 with node version 12.
Is there any way to config multiple node version on Jenkins?
THe NodeJS plugin should allow you to declare multiple NodeJS installation in the global settings
I recommend you to install nvm by default on your agents and edit the version you want to use by a simple command :
nvm use 12.4
Why?
Because installing a Jenkins plugin requires maintenance and I personally ended up with the above solution because it's more flexible and you have more control.
How to install nvm
You can use Nvm Wrapper Plugin to manage Node version with diff projects.
https://wiki.jenkins.io/display/JENKINS/Nvm+Wrapper+Plugin

I installed node.js v5.12.0 but the version showing v0.12.2

I installed Node.js from (https://nodejs.org/dist/latest-v5.x/node-v5.12.0-x64.msi), but the issue is , its showing version v0.12.2 instead of v5.12.0 which is required.
I try to update the node.js 5.2 installer but still showing version v0.12.2.
I have uninstalled Node.js and reinstall node-v5.12.0-x64.msi but still it’s not updated. Due to this am not able to run further commands for Ionic environmental setup.
Open a terminal and type where node
It should point to an old version of node (v0.12.2) still installed on your computer, for example C:\bin\node.
As Node.js is portable, you can have multiple versions on your computer.
If it cannot be uninstalled, simply delete C:\bin\node folder.
Then:
Open Windows System Properties/Advanced system properties
Click on Environment variables and edit PATH variable
Remove inside its value the path of the old version of node (C:\bin\node in our example).
Re-install Node v5.
Close your terminal and open a new one then type where node, it should point to Node.js v5
Most likely, you have an old Node version for x86 platform, and you are installing a newer version for 64 bit. Remove the path to the x86 from the Paths env variable, or move it to after the 64 bit path.
Solution:
List node.js installatios using nvm:
nvm ls
High chance the version you tried to install is also listed
Select the version to use using nvm
nvm use
(Not a direct solution)
You can try to install using nvm
Uninstall nodejs and follow the instruction from https://github.com/coreybutler/nvm-windows

Resources