Upgrading Node.js to latest version

2019-01-03 03:51发布

So, I have Node.js installed and now when I tried to install Mongoosejs I got an error telling me that I don't have the needed version of Node.js (I have v0.4.11 and v0.4.12 is needed).

How can I upgrade to this version? I suppose I just could install it again with the latest version, but I don't want to do it before I'm sure that my project folders in the folder "node" won't be deleted.

29条回答
三岁会撩人
2楼-- · 2019-01-03 04:17

Install npm =>

sudo apt-get install npm

Install n =>

sudo npm install n -g

latest version of node =>

sudo n latest 

So latest version will be downloaded and installed

Specific version of node you can

List available node versions =>

n ls

Install a specific version =>

sudo n 4.5.0
查看更多
相关推荐>>
3楼-- · 2019-01-03 04:17

sudo npm install n -g sudo n 0.12.2

or

sudo npm install -g n sudo n latest

or

sudo npm cache clean -f sudo npm install -g n sudo n latest

These work well. But for UX term terminal node -v did not show latest version so I have closed and reopened new terminal. I found v10.1.0, output of node-v after installation by sudo n latest

查看更多
疯言疯语
4楼-- · 2019-01-03 04:17

For Windows

I had the same problem, I tried to reinstall and didn't worked for me.

Remove "C:\Program Files(x86)\nodejs" from your system enviorment PATH and thats it!

查看更多
Bombasti
5楼-- · 2019-01-03 04:21

I had node version v7.10.0 in Ubuntu

Used below commands to upgrade

curl -sL https://deb.nodesource.com/setup_8.x | sudo -E bash -
sudo apt-get install -y nodejs

Now its upgraded to v8.2.1

or

sudo apt-get install make
sudo curl -L https://git.io/n-install | bash
. /home/$USER/.bashrc

# Below command should get the latest version of node
node --version

# Install specific version of node
n 8.2

# Check for the Node Version installed
node --version
查看更多
Melony?
6楼-- · 2019-01-03 04:21

After install nvm as @nelsonic describes, this is the easiest way to keep it upgraded:

"node" is a shortcut to the last version, so you can install the last version with:

nvm install node

And to always use the "node" version:

nvm alias default node

Finally to upgrade your node version and keep the installed packages:

nvm install node --reinstall-packages-from=node
查看更多
相关推荐>>
7楼-- · 2019-01-03 04:22

just run command line npm install -g npm or sudo npm install -g npmto update it for mac user. That's it.

查看更多
登录 后发表回答