I just installed Node.js and npm (for additional modules).
How can I update Node.js and the modules which I'm using to the latest versions?
Can npm do it, or do I have to remove and reinstall Node.js and npm to get the next versions?
I followed this steps in the npm section.
It's very late, but I give my answer so that it will help somebody who is stuck there. You can update in many ways as described above, so here I am discussing the most popular and easy way to update nodejs and npm.
1)Update via library n
2)Update via nvm
Open your terminal I am using Ubuntu (Linux)
1)You can install n as any node module (globally)
npm install -g n
OR
you can also install from the source if you want
cd /tmp
git clone --depth=1 https://github.com/tj/n
cd n
sudo make install
After installation hit the below command to install the latest version of node
n latest
now check node -v (you see the latest version is installed)
It will install the latest stable version of node.
n stable
Or you can install any version by adding version number against n like
n 0.10.33 # Install and use v0.10.33
You can check more regarding n in the following link click here
2)Now comes to second approach using NVM Install
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.35.3/install.sh | bash
wget -qO- https://raw.githubusercontent.com/nvm-sh/nvm/v0.35.3/install.sh | bash
After installation hit the below command to install latest version of node
nvm install node
You can list available versions using ls-remote:
nvm ls-remote
If you want to install a specific version
nvm install 6.14.4
To use any version after installation
nvm use node
Update npm to latest one
nvm install-latest-npm
Hope it will help!
Use NVM to manage node version, it will automatically take care of npm.
sudo npm install npm@latest
I run this on Linux so I am not sure about other operating systems.
sudo apt-get update
sudo apt-get upgrade
This will tell the apt-get package manager to update and upgrade all packages.
sudo n list => show the list of installed versions sudo n stable => install latest stable version.
You can also use nvm to install latest version or change between different versions.
For latest npm version: npm install -g npm@latest