Home > database >  How can I activate node version on mac
How can I activate node version on mac

Time:10-31

I try to change the node version on mac m1 pro macOs 13, I do the following commands:

  1. sudo npm cache clean -f
  2. sudo npm install -g n
  3. sudo n stable

but it is not change, the result is:

copying : node/18.12.0
installed : v18.12.0 to /usr/local/bin/node
active : v17.8.0 at /opt/homebrew/bin/node

How can I activate the installed version?

CodePudding user response:

Step 2 and 3 are the same so maybe you did it but… you can try to n uninstall 17.8.0 followed by sudo n to select the desired version.

CodePudding user response:

The active node is installed using homebrew. Therefore, you could remove the node installed using the homebrew and install it from the Mac Installer from https://nodejs.org/en/download/.

In addition to that, you might need to add the path variable to .zshrc. For that, In your terminal nano ~/.zshrc then add the line:

export PATH=$PATH:/Users/[your username]/.npm-packages/bin

Also, if you need to use multiple node versions in a single machine you can use a node version manager[1].

[1] https://github.com/nvm-sh/nvm

  • Related