macOS platform
macOS recommends using the one-click script on this site to install Node.js v22 LTS. The script will use Homebrew or nvm first and will not configure Claude, Codex or any API Key.
Recommendation: One-click installation
Execute in Terminal:
curl -fsSL https://docs.muskapi.cc/scripts/install-node.sh | bash
or:
wget -qO- https://docs.muskapi.cc/scripts/install-node.sh | bash
If your installation is slow in a domestic network environment, the script will prompt whether to use a domestic image by default. It can also be specified explicitly:
INSTALL_MIRROR=cn curl -fsSL https://docs.muskapi.cc/scripts/install-node.sh | bash
After the installation is complete, reopen Terminal and check the version again:
node -v
npm -v
npx -v
node -v displays version 22 or higher.
Alternate: Official installation package
- Open the Node.js official website.
- Download the macOS LTS installation package.
- Follow the prompts to install.
- Reopen the terminal.
- Check the version.
node -v
npm -v
npx -v
node -v displays version 22 or higher.
Alternate: Homebrew
Users who have installed Homebrew can execute:
brew install node
node -v
npm -v
If you have installed an older version of Node.js before, you can execute:
brew update
brew upgrade node
Alternate: nvm
When you need to switch Node.js versions between multiple projects, it is recommended to use nvm:
nvm install 22
nvm use 22
node -v
If the terminal prompts that nvm cannot be found, it means that nvm has not been installed or the shell configuration has not been loaded.
Terminal and permissions
- Default zsh users usually modify
~/.zshrc. - bash users usually modify
~/.bashrcor~/.bash_profile. - It is not recommended to use
sudo npm install -gto install ordinary client tools to avoid confusion about permissions and paths. - If the command cannot be found after installation, check the PATH of the current terminal.