Installation Of Node.js On MacOS

Regarding a new mac, oftentime it needs node to develope.We can use Homebrew command to install Node.js , or we may be able to directly visit the official Web to download appointed packages to conduct the installation.

Here I’ll demonstrate how to use package to install.

Go to Node.js to select a suitable version to use. To me, choosing LTS(long-term-support) version is a nice proposal here.

1
https://nodejs.org/en/download/

Download pkg of Node.js

Just follow the tips of installation step by step then you can finish it.

Here are some commands to check the version of node.js

1
2
3
4
5
6
7
#check version
npm -v
node -v

#see the registry addr
npm config get registry
#https://registry.npm.taobao.org/ it seems that the url was expired..

Change sources of dependencies.Noted that nrm(npm registry manager) is a tool of registry management.

1
npm install -g nrm

Here you may meet the issue as below sometimes.

Issue was met

A solution for reference.

https://blog.csdn.net/qq_39132095/article/details/125568802


Final solution works to my macbook air(m2 chip) as below.

  1. Create ~/.npm-global file.
1
mkdir ~/.npm-global
  1. Open and edit ~/.zshrc file.
1
vim ~/.zshrc
  1. Add below to ~/.zshrc and save it with ‘x’.
1
export PATH=~/.npm-global/bin:$PATH
  1. Reload ~/.zshrc to make it into effect.
1
source ~/.zshrc
  1. Continue to execute the installation command again.
1
npm install -g nrm

After installation of nrm, we can see the source we are currently using.

1
2
3
4
5
6
7
8
9
10
nrm ls
// * represents being used

* npm -------- https://registry.npmjs.org/
yarn ------- https://registry.yarnpkg.com/
cnpm ------- http://r.cnpmjs.org/
taobao ----- https://registry.npm.taobao.org/
nj --------- https://registry.nodejitsu.com/
npmMirror -- https://skimdb.npmjs.com/registry/
edunpm ----- http://registry.enpmjs.org/

To change the registry by following the command.

1
nrm use taobao    //change

In the end of this article,I have to say “Guys,WELL DONE!!!!“.We have already finished the installation of node.js at a macbook air with ARM64 chip.

Version Of Node.js


Installation Of Node.js On MacOS
https://iceswear.github.io/2022/11/04/InstallationOfNodejsOnMacOS/
Author
Spike Wong
Posted on
November 4, 2022
Licensed under