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-windowsinstaller: 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.exefile and follow the installation prompts. - During installation, you can choose the directory where
nvmand Node.js versions will be installed.
- Verify
nvminstallation: Open Command Prompt or PowerShell and run:nvm versionYou should see the installednvmversion.
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_modulesdirectory andpackage.jsonfile for the installed package.
Common Issues and Fixes
nvmNot Recognized:- Ensure the
nvmpath 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 thePathvariable.
- 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.
