How to Install Node.js on a Mac
See JavaScript: Tips and Tricks for similar articles.Node.js is required for using many JavaScript tools and for creating server-side JavaScript applications. Here is how you install Node.js on a Mac.
The first thing you should do is check to see if you have a version of Node.js already installed. To do that:
- Open the Terminal by pressing Command+Space to open Spotlight Search
and entering
Terminal
then pressing Enter. - Enter
node - v
in the Terminal and press Enter.Nats-MacBook-Pro:Webucator natdunn$ node -v
- If you do have Node.js installed, it will output the version.
- Update to the latest version using
npm i -g npm
. If you get a bunch ofcheckPermissions
warnings, you should run the command as the superuser like this:sudo npm i -g npm
- You now have the latest version installed. You do not need to continue with these instructions.
- Update to the latest version using
- If you do not have Node.js installed, it will output something like
-command not found
. Continue with these instructions to install it. - Go to nodejs.org. You’ll see download links for MacOS.
If you are using Node.js for a Webucator class, you should select the LTS version. The Current version has the latest features, but may be more prone to changes and bugs than the LTS (Long Term Support) version.
- When the file finishes downloading, locate it in Finder and double-click on it.
- Go through the entire installation process.
- When installation is complete, open the Terminal by pressing Command+Space to open
Spotlight Search and entering
Terminal
then pressing Enter. - Enter
node - v
in the Terminal to verify that Node.js is installed correctly and to see the version of Node.js that was installed:Nats-MacBook-Pro:Webucator natdunn % node -v v16.15.0
Installing Node.j will also install npm. To see this, runnpm -v
:Nats-MacBook-Pro:Webucator natdunn % npm -v 8.6.0
If versions for node and npm were both output, then you’re all set.
Related Articles
- Node.js and Node Package Manager (npm)
- How to Install Node.js on a Mac (this article)
- How to Run a Node.js Application on Windows
- How to Send and Receive JSON Data to and from the Server
- How to Run a Node.js Application on a Mac
- How to Open Google Chrome's JavaScript Console
- How to Create a Google Map Object with the Maps JavaScript API
- Why JavaScript is called JavaScript
- How to Learn JavaScript on Your Own
- How to Install Node.js on Windows