Upgrading Node.js to latest version
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.
n makes version-management easy:
sudo npm install n -g
For the latest stable version:
sudo n stable
For the latest version:
sudo n latest
just reinstall node from the .msi in Windows from the node website.
1 Minute Solution Without using
The current stable "LTS" version of node is 12.18.3 (2020-08-05) see: nodejs.org for latest.
Step 1 - Get NVM (Node Version Manger)
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.35.3/install.sh | bash
Step 2 - Install the version of node.js you need
Once you've got NVM you can install a specific version of Node.js using the nvm command:
nvm install v12.18.3
Note: you may need to close & re-open your terminal window for
nvm command to be available.
You should expect to see something like this in your terminal:
Now using node v12.18.3
Step 3 - Enjoy the rest of your day!
Yes, it's that easy and didn't require
Now please Upvote this (so others can avoid
and have a lovely day writing node.js code!
Microsoft Windows User? Use: https://github.com/coreybutler/nvm-windows
Review of the node mailing list indicates that using NVM (Node Version Manager) is the preferred way to manage your nodejs versioning/upgrading. see: github.com/nvm-sh/nvm
NVM is considered "better" than N because the verbose commands mean is much easier to keep track of what you are doing in your Terminal/SSH Log. Its also faster, saves kittens by not requiring
sudo and is used by the team at NPM the node.js security experts!
Read more… Read less…
On Windows download latest "Windows Installer (.msi)" from https://nodejs.org/download/release/latest/ and install same directory , thats all...
After complete the installation above, the NodeJS and NPM will be upgraded to the latest one and then you can cleanup the package as normal as:
npm cache clean npm update -g
You can always check the version with following command:
C:\node -v v0.12.4 C:\npm -version 2.10.1
All platforms (Windows, Mac & Linux)
Just go to nodejs.org and download the latest installer. It couldn't be any simpler honestly, and without involvement of any third-party stuff. It only takes a minute and does not require you to restart anything or clean out caches, etc.
I've done it via npm a few times before and have run into a few issues. Like for example with the n-package not using the latest stable release.
Upgrading node.js to the latest version on Windows
Install chocolatey if you haven't already: Installing Chocolatey
From the command prompt, type
(which is equivalent to typing
choco upgrade nodejs -- assumes you already have node installed)
NOTE: You may need to run
cinst nodejs.install for chocolatey to register your existing installation. (thanks for the comment, @mikecheel)
Installing node.js on Windows
If you have never installed node, you can use chocolatey to do that as well. Install chocolatey (see step 1 above). Then from a command prompt, type:
Installing a specific version of node on Windows with chocolatey
cinst nodejs.install -Version 0.10.26
Following Upgrading Node.js to latest version
sudo npm cache clean -f sudo npm install -g n sudo n stable sudo ln -sf /usr/local/n/versions/node/<VERSION>/bin/node /usr/bin/node
For Upgrading Node.js to latest version
sudo n latest
If you need to do Undo then follow command
sudo apt-get install --reinstall nodejs-legacy # fix /usr/bin/node sudo n rm 6.0.0 # replace number with version of Node that was installed sudo npm uninstall -g n
This method of upgrading node is now unstable and should not be used. The best way to manage Node.js versions is to use NVM: Node Version Management.!
You can read the installation steps on the nvm [GitHub page]. There are only two easy steps for installation and configuration. Using nvm
If you work with a lot of different Node.js utilities, you know that sometimes you need to quickly switch to other versions of Node.js without hosing your entire machine. That's where you can use nvm to download, install, and use different versions of Node.js:
nvm install 4.0
At any given time you can switch to another with use:
nvm use 0.12