Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Node version not updating after "nvm use" on mac

Tags:

node.js

nvm

I am trying to update my local node version from 8.9.0 to 8.10.0 using nvm. But it's not getting reflected. Here's what I tried:

node -v

-> v8.9.0

nvm use 8.10.0

-> Now using node v8.10.0 (npm v5.5.1)

node -v

-> v8.9.0

I am unable to get why it won't change. Please let me know what have I done wrong.

like image 876
psr Avatar asked Oct 06 '18 06:10

psr


People also ask

How do I update node version on Mac?

node -v. If you want to switch to the different version of Node, just type n in the terminal and you should see the Node versions listed. Use arrow keys to choose the version and press enter. I use this package in production servers too.

How do I change node versions with NVM?

Switching among Node. 7; we can simply run either nvm use 12.22. 7 or nvm use 16.13. 0 to easily switch into either version we need. Note that since we only have one version that begins with 12, 14, or 16, we can switch versions with a simple nvm use 16 , nvm use 14 , or nvm use 12 command.

How do I permanently change node version of NVM?

Just type nvm alias default v10. 16.3 in your terminal and then type nvm use default . This command will make v10. 16.3 available in any shell you open — you just have to restart your terminal to make sure it works.

Can I change npm version with NVM?

Just go with nvm use node_version . That works fine for the first time. If you upgrade run npm i -g npm from an older node version and it updates to latest, your npm version will be the latest.

How to update node version on Linux or macOS?

There are two Node version managers to choose from for Linux or MacOS, nvm or n. nvm is nothing but a script-based version manager of Node.js. You can update your version of Node.js on Linux or MacOS with Wget or cURL. Let’s say we want to install the 38.0 version of nvm, in this this example.

Should I update my NVM package?

In general, later nvm versions are compatible with earlier versions of Node, so you don’t lose anything by updating your nvm package. If you have a standard npm setup and aren’t working on a device connected to the open internet, you can ensure you have version 38 of nvm (the most current version as of this article’s date) by typing:

What is a node version manager?

A Node version manager is tool or a utility so to say, that enables developers to install different versions of Node.js and switch impeccably between them. There are two Node version managers to choose from for Linux or MacOS, nvm or n. nvm is nothing but a script-based version manager of Node.js.

What is NVM in Node JS?

Node Version Manager (NVM) is used to develop NodeJS applications in multi versions, if you install NodeJS native on your system you will quick hit the issue to change the version from eg. NodeJS 10, NodeJS 12, or the newest version at this point NodeJS 18.


2 Answers

Adding few notes about my experience on debugging this problem.

First, I started out with the command provided by Jonathan which -a node and got the same output as op:

/usr/local/bin/node
/Users/<my-user>/.nvm/versions/node/v8.10.0/bin/node

Moving on to the next comment by Jonathan: Have you installed Node via Homebrew as well?, I tried uninstalling node by brew uninstall node and got and error that said it could not uninstall node as there was another program dependent on it. yarn.

And then realised that brew had installed its own version of node because I installed yarn through brew, which was overwriting the node version that I wanted to use through nvm.

Uninstalling brew's version of yarn+node fixed my problem. I still needed yarn, and now I have to install yarn globally for each node version managed by nvm.

Inconvenient, I agree. But so is maintaining twenty thousand versions of node for each project so not very different in my opinion.

All of this was done on M1 MacOS and your output might vary based on your system.

like image 86
darth-coder Avatar answered Oct 02 '22 09:10

darth-coder


Please ensure that when you input arch on command prompt, then output is i386.

This is achieved using Rosetta.

Following sequence of commands on terminal worked: -

nvm install 8.10.0
nvm install --lts
nvm ls
brew upgrade
arch -arm64 brew install n
n

Now select node version 8.10.0 using up or down arrow keys in keyboard and then quit from command prompt using command+q

Please do not try brew uninstall --ignore-dependencies node

like image 31
S Satyen Avatar answered Oct 02 '22 08:10

S Satyen