Introduction
Node.js is a powerful JavaScript runtime that enables developers to run JavaScript on the server side, making it a key tool for modern web development. npm (Node Package Manager), which comes bundled with Node.js, is essential for managing JavaScript libraries and dependencies. If you’re using macOS, this guide will help you install Node.js and npm on your system quickly and easily.
I have no coding experience myself, and I spent hours trying to make a database work in Vercel, only to be constantly sent back to CLI (Command Line Interface) references, and thus I decided to try and install Node and Homebrew, I have just done it on my MacBook Pro, it is relatively easy, here are the steps below.
Installing Node.js and npm on macOS
Option 1: Install via Homebrew
- Open Terminal.
- If you don’t already have Homebrew installed, run the following command to install it:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
- Add Homebrew to Your PATH
After installing Homebrew, you may need to add it to your system’s PATH. Follow the instructions provided in the Terminal after the installation completes (one after the other). Replace “username” with your actual username:echo >> /Users/username/.zprofile echo 'eval "$(/opt/homebrew/bin/brew shellenv)"' >> /Users/username/.zprofile eval "$(/opt/homebrew/bin/brew shellenv)"
- Once Homebrew is set up, use it to install Node.js and npm:
brew install node
Step 2: Verify the Installation
- In Terminal, type
node -v
to check the Node.js version. - Type
npm -v
to confirm the npm version.
Option 2: Download from the Official Website
- Visit the Node.js website.
- Download the macOS installer (.pkg file).
- Open the installer and follow the on-screen instructions to complete the setup.
Conclusion
Setting up Node.js and npm is a straightforward process on macOS. By following the steps above, you’ll have Node.js and npm installed and ready to use in no time. With these tools, you can dive into server-side JavaScript development, manage dependencies, and build powerful applications. Whether you’re coding from scratch or exploring no-code platforms, Node.js opens up a world of possibilities.