Skip to content

Instantly share code, notes, and snippets.

@cwsmith-160
Last active October 12, 2025 09:25
Show Gist options
  • Save cwsmith-160/e9c8ca80f23027f0495775aed77ec780 to your computer and use it in GitHub Desktop.
Save cwsmith-160/e9c8ca80f23027f0495775aed77ec780 to your computer and use it in GitHub Desktop.
How to install node/nodejs & npx

How to install Node.js (node/nodejs, npm, and npx) in different environments

Install nodejs on Windows with PowerShell

Check if any of the required components, Chocolatey package manager, Node Version Manager, or Node.js are already installed

choco -v
nvm -v
node -v
  • Install choco if neccassary: Invoke-WebRequest -Uri 'https://chocolatey.org/install.ps1' -Outfile 'install_chocolatey.ps1'
  • Install the Node Version Manager if neccassary: choco install nvm
  • Install node with nvm: nvm install latest

Test the installation

node -v
npm -v
npx -v

choco installs environment variables in the form of windows command shell variables e.g. %NVM_HOME%. node commands may need to be run from a command shell instead or the path variables may need to be modified.

Install nodejs on Linux Subsystem for Windows (Ubuntu)

    curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/master/install.sh | bash
    nvm install --lts
@aleksadvaisly
Copy link

aleksadvaisly commented Apr 8, 2025

in my case, after nvm install latest, I've called:

nvm list

then set current version, which was shown by above list, for example:

nvm use 23.11.0

after that:

node -v

and

npx -v

finally works

@noctology
Copy link

Excellent tip and a small tip from me.

Tip

In secured Windows machines, you need to change the execution policy. If you an administrator, check it by running command below:

# Check current execution policy
Get-ExecutionPolicy

If output is:

Restricted

Run this:

Set-ExecutionPolicy RemoteSigned 
# Confirm the change
Get-ExecutionPolicy

One-liner to execute and leave things as they were:

powershell.exe -ExecutionPolicy Bypass -File .\install_chocolatey.ps1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment