How do I update Node.js?
Asked Answered
O

30

742

I did the following to update my npm:

npm update npm -g

But I have no idea how to update Node.js. Any suggestions? (I'm using Node.js 0.4.1 and want to update to Node.js 0.6.1.)

Overhang answered 19/11, 2011 at 2:37 Comment(5)
Possible duplicate: How can I update NodeJS and Npm for the next versions? . (should at the very least be linked)Robbie
Possible duplicate of Upgrading Node.js to latest versionEquipotential
I don't really get why most of the answers suggest to install third party tools :/Groos
Things have gotten quite a bit easier since this question was first answered (if you don't need version management) : All platforms (Windows, Mac & Linux)Ornas
Possible duplicate of How can I update Node.js and npm to the next versions?Morril
R
721

Use Node Version Manager (NVM)

It's a Bash script that lets you download and manage different versions of node. Full source code is here.

There is a separate project for nvm for Windows: github.com/coreybutler/nvm-windows

Below are the full steps to use NVM for multiple version of node on windows

  1. download nvm-setup.zip extract and install it.
  2. execute command nvm list available from cmd or gitbash or powershell, this will list all available version of node enter image description here
  3. use command nvm install version e.g. nvm install 12.14.0 to install on the machine
  4. last once installed use nvm use version to use newer version e.g. nvm use 12.14.0
Remembrance answered 19/11, 2011 at 2:39 Comment(13)
FYI, the command to run once having install NVM is 'nvm install <version>'. For example 'nvm install v0.8.7'Galenism
FYI: I even used nvm on an (arm) android tablet with debian. It downloads src & builds it. I upgraded v0.6.x to v0.8.x without issue.Polypetalous
You don't need this. Node is not Ruby.Cavorilievo
I really liked NVM before iojs and npm agreed to merge back together. But now it's just a hassle for little reward. Anything that thinks it knows where your node path will be automatically will need to be configured manually. Not a huge deal but kind of annoying.Gynandrous
@SimonEast There is an nvm for windows: github.com/coreybutler/nvm-windowsMesopause
@PhilHannent as per NVM github page, they don't support NVM on windows, so one can say that "there is no official NVM for windows"Atharvaveda
For windows just download latest version and install it. It will be automatically updated to new version you downloaded.Severson
michael-kuehnel.de/node.js/2015/09/08/… this is a good documentation for nvm useChancey
If you're using VS Code, don't forget to restart it after installing NVMStoush
you just want to install latest version of NodeJs from official site and it will automatically be updated. WHY BOTHER WITH NVM?Ocreate
Thank you for this answer, it led me down the right road. A couple of notes, it works better if you uninstall node if you have installed it previously, just know you will have to reinstall Angular CLI if you had it installed.Protraction
now the list command is nvm ls-remoteHereabouts
If you want latest version just run nvm install node."node" is an alias for the latest versionMaemaeander
H
1763

To upgrade Node you may first want to see which version of Node.js you are currently using:

node --version

Find out which versions of Node.js you may have installed and which one of those you're currently using:

nvm ls

List all versions of Node.js available for installation:

nvm ls-remote

Apparently for Windows the command would be rather like this:

nvm ls available

Assuming you would pick Node.js v8.1.0 for installation you'd type the following to install that version:

nvm install 8.1.0

You are then free to choose between installed versions of Node.js. So if you would need to use an older version like v4.2.0 you would set it as the active version like this:

nvm use 4.2

That should be all.


In 2013 I used the following instructions to upgrade from Node.js version 0.10.6 to 0.10.21 on a Mac, for more recent instructions see above.

Update from 2017: Please mind, Mr. Walsh himself recommended to update Node.js just using nvm instead.

  1. Clear NPM's cache:

     sudo npm cache clean -f
    
  2. Install a little helper called 'n'

     sudo npm install -g n
    
  3. Install latest stable Node.js version

     sudo n stable
    

Alternatively pick a specific version and install like this:

sudo n 0.8.20

For production environments you might want to pay attention to version numbering and be picky about odd/even numbers.

Credits

Hedgehop answered 25/10, 2013 at 8:6 Comment(18)
You should credit your source - your answer is quoted from David Walsh's blog: davidwalsh.name/upgrade-nodejs. It should also be noted that this method has major caveats, some rather destructive, as seen in the comments on the original blog post.Agile
Unfortunately that din't worked for me.. was doing exact as described on a Linux machine - 'node -v' before and after showed 'v0.10.5'Offish
One more step. Close and re-open terminal or if using ssh, exit and log back in to see new node-vHubbell
Doesn't appear to work on raspberry pi B+ most likely the utility does not support the ARM versionChromatin
did not success when node installed at a customized pathCleanse
clearing cache may not be necessary. @ShawnErquhart I found theholmesoffice.com/… which seems an older article - also the answer above doesn't appear to be a straight copy unless David Walsh's blog was updated and I missed it.Collin
why sudo everything?Gymnasiarch
@Rob Imig : Globally installed scripts usually go to places like /usr/local/bin that require special permissions for installation. Further information: github.com/npm/npm/issues/3139 A possible fix/workaround (if you really want to avoid using sudo): https://mcmap.net/q/46964/-npm-command-sudo-or-notHedgehop
This doesn't work for me on Linux. I get sudo: n: command not found for the third step.Tellurium
I already downvoted this before because it's not cross platform. However, aditionally, this also DOES NOT install latest nodejs. It installed v4 while v6.10.0 is the latest available for download.Rikki
Seems to work for me but just followed the link to David Walsh's Blog above and he explicitly says not to use it - be warned!Jovia
Thanks brianjlennon for the hint. I updated my answer from 2013 accordingly. Including credits/links. I hope that's okay.Hedgehop
you should mention that your answer is NOT cross-platform or change it accordingly. Specifically, it is NOT working for WIndows (7, for example), that was several times mentioned other users. Whtn you change it, i will take off my downvote, and may be upvote, if i like it.Rector
I know this is old but none of the other suggestions worked for me. Turned out, just clearing npm's cache workedChimene
This is a good solution if you are using a Linux distribution with deprecated packages like CentOS... Otherwise using apt upgrade to update Node.js in Debian / Ubuntu should be fine.Erect
You can also update to the current LTS or latest release by using nvm install --lts or nvm install --latest-npm. For those not wanting to type the version number every time.Havana
In order to install nvm on Windows (Win10 here), you need a POSIX compliant shell like "BashOnWindows". I highly recommend just downloading the Node installer and running it again. This will update Node and npm.Fruitage
worked like a charm on orangepi5 running armbian, had to do only one more trick because it didnt worked properly at the begin using with this answer: https://mcmap.net/q/46965/-npm-install-cannot-find-module-39-semver-39Euplastic
R
721

Use Node Version Manager (NVM)

It's a Bash script that lets you download and manage different versions of node. Full source code is here.

There is a separate project for nvm for Windows: github.com/coreybutler/nvm-windows

Below are the full steps to use NVM for multiple version of node on windows

  1. download nvm-setup.zip extract and install it.
  2. execute command nvm list available from cmd or gitbash or powershell, this will list all available version of node enter image description here
  3. use command nvm install version e.g. nvm install 12.14.0 to install on the machine
  4. last once installed use nvm use version to use newer version e.g. nvm use 12.14.0
Remembrance answered 19/11, 2011 at 2:39 Comment(13)
FYI, the command to run once having install NVM is 'nvm install <version>'. For example 'nvm install v0.8.7'Galenism
FYI: I even used nvm on an (arm) android tablet with debian. It downloads src & builds it. I upgraded v0.6.x to v0.8.x without issue.Polypetalous
You don't need this. Node is not Ruby.Cavorilievo
I really liked NVM before iojs and npm agreed to merge back together. But now it's just a hassle for little reward. Anything that thinks it knows where your node path will be automatically will need to be configured manually. Not a huge deal but kind of annoying.Gynandrous
@SimonEast There is an nvm for windows: github.com/coreybutler/nvm-windowsMesopause
@PhilHannent as per NVM github page, they don't support NVM on windows, so one can say that "there is no official NVM for windows"Atharvaveda
For windows just download latest version and install it. It will be automatically updated to new version you downloaded.Severson
michael-kuehnel.de/node.js/2015/09/08/… this is a good documentation for nvm useChancey
If you're using VS Code, don't forget to restart it after installing NVMStoush
you just want to install latest version of NodeJs from official site and it will automatically be updated. WHY BOTHER WITH NVM?Ocreate
Thank you for this answer, it led me down the right road. A couple of notes, it works better if you uninstall node if you have installed it previously, just know you will have to reinstall Angular CLI if you had it installed.Protraction
now the list command is nvm ls-remoteHereabouts
If you want latest version just run nvm install node."node" is an alias for the latest versionMaemaeander
R
665

Any OS (including Windows, Mac & Linux)

Updated October 2022


Just go to the official Node.js site (nodejs.org), download and execute the installer program.

It will take care of everything and with a few clicks of 'Next' you'll get the latest Node.js version running on your machine. Since 2020 it's the recommended way to update NodeJS. It's the easiest and least frustrating solution.

Download NodeJS for Windows, buttons

Download NodeJS for Win/Mac/Source Code buttons


Pro tips

  • NodeJS installation includes NPM (Node package manager).

  • To check your NPM version use npm version or node --version.

  • If you prefer CLI, to update NPM use npm install -g npm and then npm install -g node.

    • For more details, see the docs for install command.
  • Keep an eye on NodeJS blog - Vulnerabilities so you don't miss important security releases. Keep your NodeJS up-to-date.

  • Operating systems supported by Node.js:

    • Windows, Linux, MacOS, IBM AIX.
    • For Docker users, here's the official Node.js image.
    • For more information on installing Node.js on a variety of less-common operating systems, see this page (there's even Node for Android!).
  • Troubleshooting for Windows:

    If anyone gets file error 2502/2503 like myself during install, run the .msi via Administrator command prompt with command msiexec /package [node msi]


If my answer is helpful, don't forget to upvote it
(here is the original answer by Anmol Saraf, upvote it too)

Rinna answered 24/9, 2015 at 8:36 Comment(16)
So simple and obvious.. I was looking for a shortcut, but this way seems the simplest. node --version to check that it worked.. i had to google that too -- don't check my node version very often.Ingenerate
For those wondering if node modules will survive after running the newer version msi - the answer is yes! It worked for me too!Applecart
This didnt work for me. I have an ancient install of 0.10.26. I have been trying to install 6.10.0 LTS, but it seems impossible I can download and install 6.10.0 as many times as I want, the windows 10 machine can only see 0.10.26. In "add remove programs" I only see 6.10.0.Codicodices
Why exactly would you hyperlink operating systems' wiki pages?Presurmise
I logged to upvote this and say that it should be the accepted answer. Anyway would be nice to have a node -u with confirmation or negation. I was searching through node --help realizing very quickly that it doesn't exist. I was surprised. But anway. Download + Execute is not such a big deal.Bignoniaceous
I prefer the CLI :D and I am a windows user. npm install -g npm stable then npm install -g nodeChockablock
I did do this before I found this answer since it is not on the top, which it should.Cerumen
As usual in windows a double click is all you need to take care of the update. Can confirm having upgraded multiple times successfully simply by downloading the latest version and installing it.Breskin
As of Aug 2020 on a Mac, downloading from the node.js website seems to be the best method because "it just works". There's too many different ways to do it by CLI (just look at these answers), each those seem to have subtle conditions or unspoken assumptions, too many gotchas, and too many changes over the years. I think if you have to ask how to do this, the only answer is to download/install from node.js. Anything else is asking for confusion.Idette
If anyone gets file error 2502/2503 like myself during install, run the .msi via Administrator command prompt with command msiexec /package [node msi].Middelburg
I couldn't get the installer to work on Windows 10, installing the latest LTS version. It would always error out in PowerShell when installing the additional requirements.Dishcloth
@Dishcloth did you try with elevated permissions (run PowerShell as Administrator)?Rinna
To check your NPM version use npm version or node --version. If you prefer CLI, to update NPM use npm install -g npm and then npm install -g node. work perfectlyMelena
Worth noting that in some cases this method will require a full system reboot to the latest version fully recognized and up and running. Particularly Windows 11 seems prone to this in for one reason or another recent testing.Sita
This is simple and quick solution, this still works on node 17 and up, thank you naXaClosemouthed
This is the Obvious one and the best solution :)Radish
S
466

If you have Homebrew installed (only for macOS):

$ brew upgrade node
Seleneselenious answered 13/9, 2012 at 19:39 Comment(8)
Agreed, I just run "brew upgrade" every few days and I'm kept up to date with the latest changes for all of my packagesTlingit
This is a pain because it means having to upgrade xcode which means having to upgrade osx...Essentiality
Mine says node not installed. Note: I didn't install node with homebrew. Is there something else I should do?Outsell
How to install specific version of node using brew ?Patchy
Never mind, found it at apple.stackexchange.com/questions/171530/…Patchy
I wrote this super early in my career, and since then have had a chance to try a bunch of different techniques. I highly recommend installing n and using that if you can, à la another answer on this thread: https://mcmap.net/q/45702/-how-do-i-update-node-jsSeleneselenious
brew did some upgrade but still see the old node -v in the command lineOogonium
while using npx create-react-app . i had node version incompatibility and did upgrade to latest version of node with brew upgrade node. Successfully upgraded to v15.0.1 however i did also faced error with yarn saying No such file or directory -/usr/local/Cellar/yarn/1.22.4Blacking
O
403

2024: Just go to nodejs.org and use the latest installer.

That's it folks. It used to be more complex and people used different kinds of packages and strategies to manage it. But things have changed for the better.

Works for all platforms (Windows, Mac & Linux).

Ornas answered 8/10, 2015 at 8:14 Comment(8)
After Setup re-installation gulp didn't work. Then I called npm rebuild and it was fine again.Radford
This didnt work for me. I have an ancient install of 0.10.26. I have been trying to install 6.10.0 LTS, but it seems impossible I can download and install 6.10.0 as many times as I want, the windows 10 machine can only see 0.10.26. In "add remove programs" I only see 6.10.0. I cant find how to remove or update this old version, or how to install the new version over it. Any ideas?Codicodices
For the last comment, you can use "where" command to find the executable. For example: "where node.exe". In my system (win10) this gives "C:\Program Files\nodejs\node.exe"Osteoid
i concur, just go to nodejs.org and download and it will update everything automaticallyRespective
I tried the other solutions to this question and this one was the easiest and least frustrating.Jeffiejeffrey
I had to run this after I had downloaded the new node.js from the website: npm install -g nodeOverlying
FYI I could not get this (NPM install) working on Ubuntu 18.04.5 LTS. It would fail every time even when I chown the directories (as explained elsewhere). I also completely uninstalled my node installation, but it still wouldn't work. Finally, the only thing that I could do to get it to work was to install it via Snap. Otherwise I could only get v8.10. Snap installed v12.18.3Onward
Just in case, this doesn't work for Windows 7.Twylatwyman
L
209

First update npm,

npm install -g npm stable

Then update node,

npm install -g node or npm install -g n

check after version installation,

node --version or node -v

Lixiviate answered 20/12, 2017 at 15:34 Comment(6)
Be aware it worked for me under Windows 2016 but node was installed into the directory of the current user: C:\Users\my-current-user\AppData\Roaming\npm\...; it did not update an older installation under C:\Program Files\nodejs nor the path variable. i ended up reinstalling with the msi-installer. that fixed it for me.Tonne
This is a terrible idea. Why? Later versions of npm require later version of node. Therefore you can update npm and then it stops working as you need a newer version of node. Thus you are back to the start and now your npm is broken.Razorbill
its installs 6.8.0 for npm ,but i wants 6.11 for NodeJS, is it fine to use npm install -g npmElectrolier
After this we need to change symlink ln -sf /usr/local/n/versions/node/10.17.0/bin/node /usr/bin/nodeElevator
As with @Tonne the above method wrongly installed node into C:\Users\my-current-user\AppData\Roaming\npm. To fix: I deleted that directory (npm) and removed it from my Windows Path. Then the command node -v would work to pickup the right node version installed from nodejs.org/en/download.Linlithgow
This gave me the following warning Node.js version v19.6.1 detected. Odd numbered Node.js versions will not enter LTS status and should not be used for production. For more information, please see https://nodejs.org/en/about/releases/. And npm install just freezesBedell
M
153

On Windows you can use Chocolatey to install and update Node.js (and lots of other packages).

Install Node

cinst nodejs.install

Update Node

cup nodejs.install

Note: You will need to install Chocolatey before you can use cinst and cup.

Markley answered 11/11, 2013 at 20:35 Comment(6)
I was getting: The schema version of 'Microsoft.AspNet.Mvc' is incompatible with version 2.1.31022.9038 of NuGet. Please upgrade NuGet to the latest version from go.microsoft.com/fwlink/?LinkId=213942. When I tried to run the cup nodejs.install. Found that if I run nuget.exe update -self on the nuget.exe in the C:\Chocolatey\chocolateyinstall directory. Hope this helps anyone out there.Liveried
cinst nodejs.install Chocolatey (v0.9.8.27) is installing 'nodejs.install' and dependencies. By installing you accept the license for 'nodejs.install' and each dependency you are installing. Unable to find package 'nodejs.install'. Command 'install' failed (sometimes this indicates a partial failure). Additional info/packages: nodejs.installLava
I feel a question about how you update Chocolatey coming on.Metameric
What's the difference between nodejs.install and nodejs?Normally
@OhadSchneider if you use .install then you will be able to uninstall node from "Apps & features" in windowsMarkley
On windows I recommend using winget microsoft winget page. For me it's the smoothest experience I had with managing apps on windows. To upgrade node type winget upgrade Node.jsLianeliang
W
110

To upgrade node to the latest version or to a specific version you can do the following:

sudo npm install n -g
sudo n 0.10.18   // This will give you the specific version

For the latest stable version:

sudo n stable

For the latest LTS version(Tested on Mac)

sudo n lts
Whittling answered 22/9, 2013 at 1:17 Comment(4)
Could you not do this in 2011? Why did everybody else answer with external solutions? +1 for using NPM and deserves answer IMO.Didymium
Worked for me on an AWS EC2 Linux instanceGlarus
If you are trying to install "n" on windows, do not waste your time. At this time, still, "n" does not run on windows. For windows you either have to update from the installers on nodejs.org, use npm `npm install -g node``, use chocolaty, or install nvm (a third party version manager for node).Lasalle
@ErikReppen n is a node package. This counts as "external" for me.Promenade
N
93

To control your version of Node.js, you can try n. I found it very straightforward and useful.

n is a Node.js binary management, no subshells, no profile setup, no convoluted API, just simple.

npm install -g n

n 0.6.19 will install Node.js v0.6.19.

Newsreel answered 21/6, 2012 at 16:24 Comment(11)
Also you can switch between different nodejs versions, just type "n" and select version you needDetailed
I couldn't get it to work on Windows either. The author should publish that fact. It was a dead end for me.Paver
It works for me in Windows within the git bash shell. So if you use git fire up git bash and try it there!Amling
Doesn't work on Win7 for me - even in git bash. npm ERR! notsup Not compatible with your operating system or architecture: [email protected] npm ERR! notsup Valid OS: !win32 npm ERR! notsup Valid Arch: any npm ERR! notsup Actual OS: win32Talesman
@backdesk on windows the upgrade process is almost the same as this install process. Full instructions here: exponential.io/blog/install-or-upgrade-nodejs-on-windowsMundford
Git bash does not work for me on Windows 7, 64 bit OS.Unofficial
Git bash does not work for me on Windows 10, 64 bit OSFern
Ugh! Running this on an ARM processor, it says it's fetching a file that has the text "x86" in the title... and then promptly dies saying it cannot execute binary file (well duh!)Offish
This does not work on linux either, it downloads the correct version but doesn't install it: pastebin.com/u708hRp9Rikki
This is the best way to go if n will run on your machine.Seleneselenious
This doesn't work on my current version on node 17, but thanks anywayClosemouthed
M
63

Short answer:

Go to this page: Download | Node.js

Download the installer for your platform, then install it.

Mosra answered 26/10, 2015 at 15:19 Comment(7)
can you run it on ubuntu/LINUX ??Aneurysm
Not only for Windows, also on Mac this is the quickestStandup
The OP have not mentioned anything about the platform, so the MSI answer is valid.Mehetabel
I revised the answer to say "Download the installer for your platform" instead. You're welcome :) @AshishRatan there are Linux binaries on the same page.Mcneese
@Mcneese nvm is the best solutionAneurysm
Now working for me on UbuntuNystrom
@Nystrom Which command did you run to install it on Ubuntu?Fleurdelis
S
56

I had the same problem, when I saw that my Node.js installation is outdated.

These few lines will handle everything (for Ubuntu):

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

After this node -v will return you the latest available version.

Stevenage answered 10/6, 2014 at 7:2 Comment(5)
Worked flawlessly on Mac OS X Yosemite too.Warrick
after doing this node -v still returned an older version number. But using whereis node I could actually detect that a recent version was installed in /usr/local/bin/nodeWhereof
Worked without any hassle on Ubuntu 18.04.Mejia
@bvbd the version of node that is used (by default) in this case likely depends on the order of directories in your PATHStuddingsail
@Whereof If "node -v" shows the old version you should start a new terminalUnseal
B
23

On CentOS 7 you can do the following:

sudo npm cache clean -f
sudo npm install -g n
sudo n stable
sudo ln -sf /usr/local/n/versions/node/5.4.1/bin/node /usr/bin/node
node –v (Should show updated version now)
npm rebuild node-sass (Optional: if you use this)

Note: The symlink is required to link your node binary with the latest Node.js installed binary file.

Bettinabettine answered 18/1, 2016 at 13:29 Comment(6)
worked for me, important thing that I missed before was a symbolic linking.Bibliophage
Note that EPEL7 as of now has the latest long term stable version, so these steps are only recommended if you want something newer.Torrietorrin
node –v module.js:473 throw err; ^ Error: Cannot find module '/root/test/–v'Experimentation
n latest /usr/bin/n: line 263: which: command not found /usr/bin/n: line 263: which: command not foundExperimentation
@AlexeySh. It worked for me and apparently at least 16 other people.Bettinabettine
For windows:-The NPM team officially recommends this method of updating Node. (source below) matthewhorne.me/how-to-update-npm-on-windows-10 1.First, open PowerShell as administrator and run the following command. >Set-ExecutionPolicy Unrestricted -Scope CurrentUser -Force >npm install -g npm-windows-upgrade >npm-windows-upgradeEpigene
N
14

For OS X, I had v5.4.1 and needed the latest version 6 so I went to the Node.js homepage and clicked on one of the links below:

Node.js OS X download links

I then followed the installer and then I magically had the latest version of Node.js and npm.

Norther answered 2/7, 2016 at 9:2 Comment(0)
R
9

You may use nvm.

  1. Check what is the latest version at http://nodejs.org/ (e.g. v0.10.26)
  2. Run nvm install v0.10.26

Done.

You can choose which version to run:

nvm ls list the available versions and tells you which version you are using now.

nvm use VERSION change the current node to the requested version.

nvm alias default VERSION set the default version. The next time you source nvm.sh, this will be the version loaded (note that it doesn't change the version in use right now, run nvm use for that).

Recipient answered 4/3, 2014 at 22:48 Comment(4)
nvm is third party library :PBlouson
This is embarrassing. I used it since day one and didn't notice. I'll edit the answer.Recipient
nvm alias default VERSION was my savior!Pisistratus
I would also add nvm copy-packages <previous version> to update all global dependencies at the endGlyceride
J
9

For macOS in 2018+ (as ALL of the solutions above are failing for me):

Simply go to the official nodejs site, download the official nodejs package and install it by double clicking. It's the most simple, safe and always-working thing you can do.

Jeweller answered 19/7, 2018 at 11:26 Comment(0)
T
8

Some Linux distributions such as Arch Linux have Node.js in their package repositories. On such systems it is better to use a standard package update procedure, such as pacman -Suy or analogous apt-get or yum commands.

As of now (Nov 2016) EPEL7 offers a pretty recent version of Node.js (6.9.1 which is an up-to-date LTS version offered on the Node.js home page). So on CentOS 7 and derivatives you can just add EPEL repository by yum install epel-release and yum install nodejs.

CentOS 6/EPEL6 has 0.10.x which isn't supported upstream since Oct 2016.

Torrietorrin answered 20/11, 2011 at 10:28 Comment(0)
M
7

Today I ran on a Windows Git Bash:

$ npm i node -g

and got the following output:

> [email protected] preinstall C:\Users\X\AppData\Roaming\npm\node_modules\node
> node installArchSpecificPackage

+ [email protected]
added 1 package and audited 1 package in 23.368s
found 0 vulnerabilities

C:\Users\X\AppData\Roaming\npm\node -> C:\Users\X\AppData\Roaming\npm\node_modules\node\bin\node
+ [email protected]
added 2 packages from 1 contributor in 26.089s

Read more about it at https://www.npmjs.com/package/node.

Motion answered 13/7, 2018 at 1:16 Comment(1)
Same here. Out of nowhere my nodejs is deinstalledGrizzle
R
6

The easy way to update node and npm :

npm install -g npm@latest

download the latest version of node js and update /install

Rabideau answered 25/11, 2017 at 16:17 Comment(1)
you can drop the @latest part, it's the default behavior for npm.Metabolize
A
5
$ npm install -g npm stable

worked for me to update npm

Absinthism answered 25/8, 2016 at 6:14 Comment(1)
This is to update npm and the question is for updating nodejsCrin
Q
5
Quartana answered 21/2, 2017 at 19:55 Comment(1)
NB: This will copy nvm.sh to your home directory. You should then run source ~/.nvm/nvm.sh to set up the nvm command. Now you you can run nvm ls, etc as listed above. This is only necessary if you do not want to have to re-open your terminal, e.g. if you are SSH'd into a remote server.Turncoat
L
4

For Ubuntu:

sudo apt-get install -y curl
curl -sL https://deb.nodesource.com/setup_0.12 | sudo bash -
sudo apt-get install -y nodejs

Source: https://askubuntu.com/questions/426750/how-can-i-update-my-nodejs-to-the-latest-version

Laxation answered 2/7, 2015 at 16:34 Comment(3)
curl {anything} | sudo bash - can't possibly be a good security practice... Even leaving sophisticated attacks aside, what if you misspell the domain name?Upward
Your comment adds no value to the answer. You can also misspell your bank domain and leak your bank details in a fake bank website.Laxation
Do not do npm i n -g afterwards to update node, because then you get two nodes on your system. Stay with this update process of apt. Alternatively you can try snap which also has a built-in update functionLytle
K
4

You may use Chocolatey on Windows. It's very easy to use and useful for keeping you updated with other applications too.

Also, you can just simply download the latest version from https://nodejs.org and install it.

Kenley answered 9/3, 2016 at 13:58 Comment(1)
He asked "I did the following to update my npm: "npm update npm -g" But I have no idea how to update node.js. Any suggestions? (I'm using node.js 0.4.1 and want to update to node.js 0.6.1)." and I suggested him to use Chocolatey to simplify the process but I also suggested him to download the latest version from the site and install it, wich is more than enough to update the nodeJS as he asked. So, I think my answer does provide a satisfactory solution for his question.Kenley
A
4

According to Nodejs Official Page, you can install&update new node version on windows using Chocolatey or Scoop

Using(Chocolatey):

cinst nodejs
# or for full install with npm
cinst nodejs.install

Using(Scoop):

scoop install nodejs

Also you can download the Windows Installer directly from the nodejs.org web site

Alpenhorn answered 11/11, 2017 at 5:42 Comment(0)
E
3

As some of you already said, the easiest way is to update Node.js through the Node.js package manager, npm. If you are a Linux (Debian-based in my case) user I would suggest to add these lines to your .bashrc file (in home directory):

function nodejsupdate() {
    ARGC=$#
    version=latest
    if [ $ARGC != 0 ]; then
        version=$1
    fi
    sudo npm cache clean -f
    sudo npm install -g n
    sudo n $version
}

Restart your terminal after saving and write nodejsupdate to update to the latest version of Node.js or nodejsupdate v6.0.0 (for example) to update to a specific version of Node.js.

BONUS: Update npm (add these lines to .bashrc)

function npmupdate() {
    sudo npm i npm -g
}

After restarting the terminal write npmupdate to update your node package manager to the latest version.

Now you can update Node.js and npm through your terminal (easier).

Errant answered 4/5, 2016 at 17:33 Comment(0)
R
3

In windows download the node executable file from the website and install it. this worked for me.

Reinforce answered 20/12, 2017 at 14:18 Comment(0)
T
1

All you need to version update of Node.js:

$ brew install node

If you don't have Homebrew; please go http://brew.sh/.

Tame answered 16/10, 2016 at 22:36 Comment(3)
Homebrew doesn't work on all platforms that Node.js does.Wahl
Homebrew won't update a version of Node.js installed through some other means either. It will install parallel to it.Unwelcome
brew upgrade nodeAhmad
B
0

Just install the new version over the current folder. I upgraded mine from v4.x to v6.10 on Windows.

Badillo answered 4/3, 2017 at 16:25 Comment(0)
M
-3
  1. npm clean cache - you forget to clean ur cache

  2. npm update -g

    This works on mine Windows, I hope it will also work for you :D

Minicam answered 27/8, 2015 at 9:14 Comment(2)
npm cache clean (a different order)Rinna
npm update -g command updates all globally installed packages, but not node.js itself.Rinna
O
-5

If you want to update Node.js, just try

npm update

from your Windows cmd prompt.

Else if you want to update any specific package try

npm update <package_name>

Example:

npm update phonegap
Obey answered 24/1, 2014 at 13:54 Comment(3)
That's a great answer for a different question.Earthquake
This does not work for me. Before doing nmp update, node --version says 0.10.26. After doing update, same version. Even though the latest version is 7.7.1 or similar.Codicodices
This didn't work for me either.Hatbox
R
-10

open cmd and type

npm i -g npm
Rawboned answered 20/6, 2018 at 3:58 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.