I want to upgrade node to 12.10.0 and npm to 6.11.3, currently I am working on macOS Mojave version 10.14.5
I am using these commands to upgrade the node version to 12.10.0::
sudo npm cache clean -f
(force) clear you npm cachesudo npm install -g n
install n (this might take a while)sudo n 12.10.0
upgrade to the specific versionAfter running the last command it gives me an output like::
installing : node-v12.10.0
mkdir : /usr/local/n/versions/node/12.10.0
fetch : https://nodejs.org/dist/v12.10.0/node-v12.10.0-darwin-x64.tar.gz
installed : v12.10.0 to /usr/local/bin/node
active : v10.16.3 at /usr/local/opt/node@10/bin/node
When I am checking for node version node -v
it still shows me old version 10.16.3
I have tried to add node path, but still, it gives me the same output.
I have used command sudo nano /etc/path
and then added /usr/local/bin/node
path to it.
Please suggest me how can I upgrade node to 12.10.0 and npm to 6.11.3 version?
Switch Node via alias Now, to switch between the node versions, enter an alias node10 in your terminal. Execute node -v to verify that you are now using the correct node version.
Install nvm following below tutorial :
Install nvm with homebrew
As stated in the link above,
Start by :
brew update
brew install nvm
mkdir ~/.nvm
nano ~/.bash_profile
In your .bash_profile file (you may be using an other file, according to your shell), add the following :
export NVM_DIR=~/.nvm
source $(brew --prefix nvm)/nvm.sh
Back to your shell, activate nvm and check it (if you have other shells opened and you want to keep them, do the same) :
source ~/.bash_profile
echo $NVM_DIR
Then with the help nvm install any node version(example v12.14.1) you want :
nvm install v12.14.1
nvm use v12.14.1
to switch to 12.14.1 version.
install n (npm module) npm install -g n
and run sudo n latest
or sudo n <version>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With