Home > Article > Web Front-end > How to install Node.js on Mac
Node.js is a JavaScript runtime environment based on the Chrome V8 engine. It enables JavaScript to run on the server side, which allows developers to write server-side applications in JavaScript. The emergence of Node.js not only unifies the development languages of the front-end and back-end, but also greatly improves development efficiency.
This article will introduce how to install Node.js on Mac system. The installation of Node.js is roughly divided into the following two methods:
Method 1: Download the installation package through the official website
node -v
If the version number appears, the installation is successful. .
Method 2: Install NVM through the command line
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
brew install nvm
mkdir ~/.nvm nano ~/.bash_profile
export NVM_DIR=~/.nvm source $(brew --prefix nvm)/nvm.sh
Save and exit the file.
source ~/.bash_profile
nvm ls-remote
nvm install 版本号
For example, install the latest version of Node.js:
nvm install node
node -v
If the version number appears, it means the installation is successful.
So far, the two methods of installing Node.js on Mac systems have been introduced. If you want to uninstall Node.js, you can enter the following command in the terminal:
sudo rm -rf /usr/local/{bin/{node,npm},lib/node_modules/npm,lib/node,share/man/man1/node.1.gz}
Note: Before executing, please make sure to back up the files that need to be retained.
The above is the detailed content of How to install Node.js on Mac. For more information, please follow other related articles on the PHP Chinese website!