Home > Software engineering >  Why doesn't "n" downgrade my node version on a Mac?
Why doesn't "n" downgrade my node version on a Mac?

Time:12-10

I’m using Mac Big Sur. I want to downgrade the version of Node. I tried the below (installing without sudo gives me permission errors) …

$ sudo n 14.15.1
   installed : v14.15.1 to /usr/local/bin/node
      active : v14.17.6 at /usr/local/opt/node@14/bin/node

But I still get the current version when I check

$ node -v
v14.17.6

Fwiw, here’s what I see with “which node”

$ which node
/usr/local/opt/node@14/bin/node

CodePudding user response:

The n message is telling you that the version it just "installed" and the version that is "active" are different. You have two versions of node installed, and the active version is the one that is first in the PATH.

The active version is /usr/local/opt/node@14/bin/node. I don't recognise that path, not sure what was used to install that. It must be in your PATH variable and there might be a clue in your login script as to what added /usr/local/opt/node@14/bin to the PATH?

To get the n installed version of node to be the active version, you could delete the other copy of node, or put /usr/local/bin earlier in PATH so it is found first.

CodePudding user response:

If you're going to use multiple node versions like at nvm:

nvm install <version>

Change version with:

nvm use <version>

Docs:

https://github.com/nvm-sh/nvm

  • Related