Skip to content
X

Node.js Installation and Initial Setup

Node.js is a runtime environment that lets you run JavaScript outside the browser, such as on servers or in the terminal. It is used for front-end development, back-end development, CLI tools, and AI-integrated applications.

This page explains how to install Node.js with nvm and create your first project.

You can install Node.js directly with the official installer or Homebrew, but using nvm has several advantages:

  1. Multiple versions can coexist - You can use different Node.js versions per project.
  2. You do not need sudo - Permission errors are less likely, and global package management is safer.
  3. Version switching is easy - Switch with a single nvm use <version> command.

Check that Homebrew is installed.

brew --version
# Example: Homebrew 4.x.x

If it is not installed, finish Homebrew Installation first.

Check that nvm is installed.

command -v nvm
# If "nvm" is shown, you are good

If it is not installed, finish Installing nvm first.

Install Node.js with nvm.

nvm install --lts        # Install the latest LTS release
node -v                  # Check version, for example v22.x.x
npm -v                   # Check npm version, for example 10.x.x

The LTS (Long Term Support) release is stable and supported for a long time. I recommend LTS for new projects.

Step 4: Update npm to the latest version (optional)

Section titled “Step 4: Update npm to the latest version (optional)”

Update npm, which is installed with Node.js, to the latest version.

npm install -g npm
npm -v                   # Check the version after the update

After installation, create a simple project to confirm that everything works.

mkdir my-first-project   # Create a project folder
cd my-first-project      # Move into the folder
npm init -y              # Generate package.json automatically

Running npm init -y creates a package.json file. This file is used to manage project information and dependencies.

ls                       # Confirm that package.json was created

Run the following commands to confirm that everything is installed correctly:

node -v     # Example: v22.x.x
npm -v      # Example: 10.x.x
nvm current # Current Node.js version in use

Q: node: command not found appears

A: nvm may not be configured correctly. Run source ~/.zshrc for Zsh or source ~/.bashrc for Bash to reload the shell. If that does not help, review the steps in Installing nvm.

Q: EACCES: permission denied appears during npm install

A: This means the global npm install location is not writable. If you installed Node.js through nvm, this should not happen. To avoid using sudo, standardize on nvm-based installation.

Q: package.json not found

A: You are running the command in a folder that does not contain package.json. Run npm init -y first, or cd into the project folder and try again.

  • Install Node.js through nvm
  • Use nvm install --lts to install the latest LTS release (v22 series in 2026)
  • Use npm init -y to create the project package.json
  • Use node -v and npm -v to confirm the installation