1. Information

2. Linux

2.1. Installation with nvm (Node Version Manager)

  • Install NVM for Linux.

  • Enter the following commands at a Command Line.

    nvm list
    nvm install --lts
    nvm list
    nvm use --lts
    nvm
    
    node --version                          # v24.14.1
    npm --version                           # 11.11.0
    npx --version                           # 11.11.0

2.2. Installation

  • Enter the following commands at a Command Line.

    # Dependencies.
    sudo apt-get update
    sudo apt-get --yes install curl
    # Optional development tools to build native addons.
    #sudo apt-get --yes install gcc g++ make
    
    
    # Installation.
    curl -sL https://deb.nodesource.com/setup_24.x   | sudo -E bash -
    cat /etc/apt/sources.list.d/nodesource.list
    sudo apt-get --yes install nodejs
  • Enter the following optional commands at a Command Line.

    which node nodejs npm npx nvm
    node -v                                 # v10.15.2      # v12.22.0      # v14.17.2
    nodejs -v                               # v10.15.2      # v12.22.0      # v14.17.2
    npm -v                                  # 6.4.1         # 6.14.11       # 6.14.13
    npx -v                                  # 6.4.1         # 6.14.11       # 6.14.13

2.3. Uninstallation

  • Enter the following commands at a Command Line.

    echo $PATH | grep --color -i node
    echo $PATH | grep --color -i npm
    echo $PATH | grep --color -i nvm
    dpkg -l | grep -i node
    dpkg -l | grep -i npm
    dpkg -l | grep -i nvm
    sudo grep -ir --exclude-dir={cron.d,init,init.d,iscsi,logrotate.d,lvm,lynx-cur,munin,openvpn,php,php5,sane.d,X11} '\<node\>' /etc
    sudo grep -ir '\<npm\>' /etc
    sudo grep -ir '\<nvm\>' /etc
    which node nodejs npm npx nvm
    sudo apt-get purge nodejs
    sudo rm -rf /usr/lib/node_modules
    sudo rm -rf ~/node_modules
    sudo rm -rf ~/.npm
    sudo rm -rf ~/.nvm

Log off and log on again.

2.4. Update

  • Enter the following commands at a Command Line.

    sudo apt-get update
    sudo npm install -g npm
    npm -v                                  # 6.8.0         # 7.20.0
    npx -v                                  # 6.8.0         # 7.20.0

2.5. Save a list of pre-installed packages

This is useful to see what additional packages have been installed since Node.js was installed.

  • Enter the following commands at a Command Line.

    npm list -g --depth 0 | sudo tee ~root/nodepackages.org > /dev/null

3. OS-X

This section is out of date and needs to be updated.

3.1. Installation

  • Download the latest stable source code from the nodejs.org[Node.js^] website.

Enter the following commands at a Command Line.

sudo ln -s /usr/local /opt
cd /tmp
tar xfz ~/Downloads/node-v0.8.14.tar.gz
cd node-v0.8.14
./configure --prefix=/usr/local/node
make
sudo make install

Contents of the /etc/paths.d/node file.

/usr/local/node/bin

Contents of the /etc/manpaths.d/node file.

/usr/local/node/share/man

Enter the following optional commands at a Command Line.

which node nodejs npm npx nvm
node -v
npm -v

3.2. Uninstallation

Enter the following commands at a Command Line.

cd /tmp
tar xfz ~/Downloads/node-v0.8.14.tar.gz
cd node-v0.8.14
sudo make uninstall
rm -rf ~/.npmrc
rm -rf ~/.npm

4. Windows

4.1. Installation with nvm (Node Version Manager)

  • Install NVM for Windows.

  • Enter the following commands at a Command Prompt with administrative privileges.

    nvm install 8
    nvm list available
    nvm install 8.11.3
    nvm list
    nvm use 8.11.3                  ???
    nvm alias default 8.11.3        ???
  • Optional: Restart the computer?

  • Enter the following optional commands at a Command Line.

    where node nodejs npm npx nvm
    node -v                                         # v8.11.3
    npm -v                                          # 5.6.0

4.2. Installation with msi

  • Download the latest stable installer from the Node.js website.

  • Run the node-v8.11.3-x64.msi or node-v8.11.3-x86.msi file.

  • Click Next.

  • Check I accept the terms in the License Agreement.

  • Click Next.

C:\Program Files\nodejs
  • Click Next.

+ Node.js runtime
  + Performance counters
  + Event tracing (ETW)
+ npm package manger
+ Online documentation shortcuts
+ Add to PATH
   + Node.js and npm
   + npm modules
  • Click Next.

  • Click Install.

  • Wait.

  • Click Finish.

Enter the following optional commands at a Command Line.

where node nodejs npm npx nvm
node -v                                         # v8.11.3
npm -v                                          # 5.6.0

4.3. Configuration

Get list of user-intalled packages.

npm list                                        # For local modules
npm list --depth=0                              # For local modules
npm list -g                                     # For global modules
npm list -g --depth=0                           # For global modules
npm root -g                                     # C:\Program Files\nodejs\node_modules
dir "C:\Program Files\nodejs\node_modules"

4.4. Update

Enter the following commands at a Command Prompt with administrative privileges.

cd C:\Program Files\nodejs
npm -v                                          # 4.2.0
npm install npm@latest
npm -v                                          # 6.1.0
npx -v                                          # 6.1.0

4.5. Uninstallation

Enter the following commands at a Command Prompt with administrative privileges.

echo %Path% | findstr /i "node"
echo %Path% | findstr /i "npm"
set LF=^& echo & set "Tmp=%Path%" & echo !Tmp:;=^%LF%! | findstr /a:0e /n /i "node"
set LF=^& echo & set "Tmp=%Path%" & echo !Tmp:;=^%LF%! | findstr /a:0e /n /i "npm"
where node nodejs npm npx nvm
rmdir /q /s "C:\Program Files\Nodejs"
rmdir /q /s "C:\Program Files (x86)\Nodejs"
rmdir /q /s "C:\Users\<User>\AppData\Roaming\npm"
rmdir /q /s "C:\Users\<User>\AppData\Roaming\npm-cache"
rmdir /q /s "C:\Users\<User>\AppData\Local\Temp\npm-*"
del /a /f /q "C:\Users\<User>\.npmrc"

Remove any entry from the Path system variable.

Restart the computer.