Installing Node.js and npm on Windows 11 using a Node Version Manager (nvm-windows
) is straightforward. Follow these steps:
Step 1: Download and Install nvm-windows
- Download the
nvm-windows
installer: Visit the official nvm-windows releases page and download the latestnvm-setup.zip
. - Run the Installer:
- Extract the downloaded zip file.
- Run the
nvm-setup.exe
file and follow the installation prompts. - During installation, you can choose the directory where
nvm
and Node.js versions will be installed.
- Verify
nvm
installation: Open Command Prompt or PowerShell and run:nvm version
You should see the installednvm
version.
Step 2: Use nvm-windows
to Install Node.js and npm
- List available Node.js versions:
nvm list available
- Install the latest LTS version of Node.js:
nvm install lts
- Set the default Node.js version:
nvm use lts
- Verify installation:
node --version npm --version
Step 3: Update npm to the Latest Version
To update npm to the latest version globally, run:
npm install -g npm
Step 4: Test Your Installation
- Create a simple Node.js project:
mkdir test-node cd test-node npm init -y
- Install a package (e.g., Express):
npm install express
- Verify the installation: Check the
node_modules
directory andpackage.json
file for the installed package.
Common Issues and Fixes
nvm
Not Recognized:- Ensure the
nvm
path is added to your environment variables:- Press
Win + S
, typeEnvironment Variables
, and open it. - Add the path to
nvm
(e.g.,C:\Program Files\nvm
) and the path to Node.js (e.g.,C:\Program Files\nvm\vX.X.X
) to thePath
variable.
- Press
- Ensure the
- Permission Issues:
- Always run your terminal as an Administrator to avoid permission problems.
- Switching Node.js Versions: You can install and switch between multiple Node.js versions using:
nvm install <version> nvm use <version>
Now, you’re ready to use Node.js and npm on Windows 11! Let me know if you encounter any challenges.