Diego De La Puente

Install Node.js and npm on Windows

1. Overview

To install Node.js on Windows, we will use the Bash Git terminal. This "How-To" assumes you have Bash Git installed, as the commands we will be use are Unix-based, unlike Windows' DOS commands which I am less familiar with. Node.js offers several download options on its download website page, ensure you are pointing to a Long Term Support (LTS) version. We will opt for using the FNM (Fast Node Manager) client command line install, once the Fast Node Manager is installed then we will be able to install Node.js and npm. These install steps ensure uniformity across Windows, Linux and MacOS. FNM installs simplify the installation process by installing both simultaneously:

  1. Node.js
  2. nmp

Node.js and npm are installed at the same time. At the end of the install we will ensure Node.js was successfully installed by testing it live using the REPL (Read-Evaluate-Print-Loop). Note that that REPL will not work in git bash but you can create a .js file and call it from git bash successfully as a test.

FNM FNM (Fast Node Manager) is a command-line tool for managing multiple versions of Node.js. It is designed to be fast and efficient, providing a lightweight alternative to other Node version managers like nvm (Node Version Manager). FNM is optimized for speed, making it faster than many other Node.js version managers. FNM downloads and manages Node.js binaries and can support different versions concurrently on a given machine.
Node.js Node.js is a JavaScript runtime built on Chrome's V8 JavaScript engine. In the Angular ecosystem, Node.js is used to run the development server, build tools, and scripts, providing an environment to execute Angular commands. Basically Node.js provides the ecosystem for Angular projects.
npm npm (Node Package Manager) is used to manage the dependencies required for Angular development. It allows you to install, update, and manage packages, such as Angular CLI and other libraries, ensuring your Angular application has the necessary tools and libraries. NPM acts as a tool for running the Angular development server and managing various tasks in an Angular project.

2. Installation Steps


# RUN THE FOLLOWING IN A GIT BASH TERMINAL
# ENSURE ANTI-VIRUS IS DISABLED DURING INSTALL
# installs fnm (Fast Node Manager)
curl -k -fsSL https://fnm.vercel.app/install | bash
Downloading the latest fnm binary from GitHub...
Checking dependencies for the installation script...
Checking availability of curl... OK!
Checking availability of unzip... OK!
Downloading https://github.com/Schniz/fnm/releases/latest/download/fnm-windows.zip...
######################################################################## 100.0%
# ENSURE FNM LOCATION IS ADDED TO $PATH AT .bashrc USER FILE
# CHANGE FNM PATH FROM DOUBLE QUOTES TO SINGLE QUOTES
# THIS IS TO DEAL WITH THE SPACE BETWEEN FIRST & LAST NAME
FNM_PATH='/c/Users/FirstName LastName/.local/share/fnm'
if [ -d "$FNM_PATH" ]; then
  export PATH="$FNM_PATH:$PATH"
  eval "`fnm env`"
fi

# ENSURE FNM IS INSTALLED
fnm --version
fnm 1.37.1

# ENSURE FNM IS EXPORTED TO THE ENVIRONMENT AS PATH VARIABLES
# THERE WILL BE ADDITIONAL FNM VARIABLES ALSO INCLUDED
env | grep -i "FNM"

# ONCE FNM ENV VARIABLES ARE EXPORTED TO env
# EXCUTE THE download and install Node.js COMMAND
fnm use --install-if-missing 20
Installing Node v20.14.0 (x64)
00:00:01 ████████████████████████████████ 28.09 MiB/28.09 MiB (14.79 MiB/s, 0s)

# CHECK NODE AND NPM WERE INSTALLED:
# verifies the right Node.js version is in the environment
node -v # should print your corresponding download version
# verifies the right NPM version is in the environment
npm -v # should print your corresponding download version
# returns node install location
which node
#/c/Users/FirstName LastName/AppData/Local/fnm_multishells/55312_1718652930491/node


# ADD NODE PATH RETURNED BY `which node` AND BASE DIRECTORY TO .bashrc
export PATH="/c/Users/FirstName LastName/AppData/Local/fnm_multishells/70788_1718430928927/node:$PATH"
export PATH="/c/Users/FirstName LastName/AppData/Local/fnm_multishells/70788_1718430928927/:$PATH"

3. Windows Command Terminal REPL test

Since the REPL does not function on git bash we will test this by open a standard windows Command prompt. We are going to ensure Node.js is running by being able to input JavaScript code at the command prompt and it successfully being able to interpret JavaScript.


# ENSURE NODE LOCATION IS LISTED IN WINDOWS ENV PATH
# IF NOT, ADD IT WITH THE FOLLOWING COMMAND
setx PATH "%PATH%;C:\Users\FirstName LastName\AppData\Local\fnm_multishells\70496_1718431513152"

# RUN NODE AS FOLLOWS:
C:\Users\UserName>node
#Welcome to Node.js v20.14.0.
#Type ".help" for more information.
> console.log("Node.js is functioning");
Node.js is functioning
undefined
> .exit

# THIS TEST SHOWS NODE REPL FUNCTIONALITY

4. Media

Windows Installation Screenshot

Install Node.js and npm on macOS

1. Overview

This section covers how to install Node.js and npm on a macOS system. Node.js can be installed via a package manager or directly from the Node.js website.

2. Installation Steps


public class Main {
    public static void main(String[] args) {
        System.out.println("Hello, Java!");
        int a = 10;
        int b = 20;
        int sum = a + b;
        System.out.println("Sum of " + a + " and " + b + " is: " + sum);
    }
}

3. Media

macOS Installation Screenshot