Install nodejs 4.2.0 or above version

2019-07-07 04:52发布

问题:

I have installed node and npm using following command in my Ubuntu machine:

sudo apt-get install nodejs npm

On checking version of installed, I could see following:

$ node -v && npm -v
v0.10.25
1.3.10

But I want nodejs version to be 4.2.0 or above. I am trying to install VSO Linux agent for a project. On executing node agent/vsoagent, I get error that node version should be 4.2.0 or above.

How do I install it and also make sure that the already installed ones are removed with node -v && npm -v gives me new version number?

Thanks

回答1:

You already have npm, so you can use n manager to install any version you want (4.4.4 for ex): maybe you should use sudo for global install:

npm install -g n 
n 4.4.4

Or

n latest

After that you can just run n to select version that you prefer. I use latest LTS and latest 6.x side-by-side and switching them anytime i want.