To install Node.js and npm on Windows, download the LTS installer from the official Node.js website and run it, accepting the defaults. This installs both Node.js and npm, and after a quick verification in the Command Prompt, you’ll be ready to use them. The process takes about five minutes and works on Windows 10 and Windows 11.
What Are Node.js and npm?
Node.js is a JavaScript runtime that lets you run JavaScript code outside a web browser, on your computer or server. It’s built on Chrome’s V8 engine and is widely used for building web servers, command-line tools, and desktop applications. npm (Node Package Manager) is the default package manager that comes with Node.js; it downloads and manages libraries and tools that your projects depend on, similar to how pip works for Python or gem for Ruby.
When you install Node.js, you get both the node command (to run scripts) and the npm command (to install packages). The npm registry hosts over two million packages, from small utilities like lodash to full frameworks like express or react.
Prerequisites and System Requirements
Before you begin, make sure your Windows version is supported. Node.js officially supports Windows 10 and Windows 11 (64-bit). For older versions like Windows 7 or 8, you’d need an outdated Node.js version, which is not recommended for security reasons.
- Administrator rights: The installer needs permission to write to
C:\Program Filesand update the system PATH. You’ll see a User Account Control prompt; click “Yes”. - Internet connection: You need to download the installer and later fetch packages from the npm registry.
- Disk space: The base install is about 200 MB, but packages can add up quickly. A few gigabytes free is a safe margin.
- No existing installation: If you already have Node.js, check its version first. You might only need to update, not reinstall.
Step-by-Step Installation Guide
- Go to nodejs.org and click the green button labeled “LTS” (Long-Term Support). This is the stable version recommended for most users. The current release (with the latest features) is fine for experimentation but may have more frequent updates.
- Run the downloaded
.msifile. The installer wizard opens. - Click “Next” through the welcome screen and license agreement. Accept the default installation directory (
C:\Program Files\nodejs). - On the “Custom Setup” page, leave all features checked. The default includes the Node.js runtime, npm, and shortcuts.
- On the “Tools for Native Modules” page, you can leave the checkbox unchecked unless you plan to compile native add-ons (like some database drivers). You can always install these tools later.
- Click “Install” and wait for the progress bar to finish. If Windows prompts for permission, click “Yes”.
- Click “Finish” to close the wizard.
- Open a new Command Prompt (or PowerShell) window. This is important: the PATH environment variable is updated during install, but only new windows pick up the change.
Verifying the Installation
To confirm everything works, type these two commands in the Command Prompt:
node --version
npm --version
You should see output like v20.11.1 (for Node) and 10.2.4 (for npm). The exact numbers depend on the version you installed. If you see “not recognized as an internal or external command,” the PATH wasn’t set correctly, or you didn’t open a new window.
To test that Node.js actually runs code, create a file named test.js with the line console.log('Hello, Node!');, then run node test.js in the same folder. You should see the message printed.
Choosing Between LTS and Current Versions
Node.js releases two main lines: LTS (Long-Term Support) and Current. The LTS version is recommended for most users because it receives security patches and bug fixes for several years. The Current version includes new features but is only supported for a few months until the next release. For learning, building small tools, or starting a new project, LTS is the safe choice. If you need a specific feature that only exists in the Current version, you can install that instead, but be prepared to upgrade more often.
If you work on multiple projects that require different Node.js versions, consider using a version manager like nvm-windows (Node Version Manager for Windows). It lets you install and switch between versions easily. This is useful if you maintain older projects that depend on an older Node.js runtime.
Common Installation Problems and Fixes
Even with a straightforward installer, a few issues can arise:
- “node is not recognized” – This usually means the PATH doesn’t include the Node.js directory. Reopen your terminal, or manually add
C:\Program Files\nodejsto your system PATH via System Properties → Environment Variables. - Installation fails with error 2502 or 2503 – These errors often relate to permissions. Run the installer as Administrator (right-click → Run as administrator) and try again.
- npm is slow or times out – The default npm registry can be slow in some regions. You can switch to a faster mirror with
npm config set registry https://registry.npmmirror.com(for China) or use a corporate proxy if you’re behind one. - Node.js installs but npm doesn’t – This is rare. If npm is missing, reinstall Node.js with the “Repair” option from the installer, or install npm separately (not recommended).
- Antivirus blocks the installer – Some security software may flag the installer. Temporarily disable it, run the install, then re-enable it. Only do this if you trust the source (nodejs.org).
Keeping Node.js and npm Updated
Node.js itself doesn’t auto-update. To update, download the new installer from nodejs.org and run it over your existing installation. This preserves your globally installed packages. Alternatively, use a version manager to switch versions more cleanly.
For npm, you can update it independently with npm install -g npm@latest. This updates npm to the latest version without touching Node.js. It’s a good idea to check for updates every few months, as both Node.js and npm receive security patches regularly.
Frequently Asked Questions
Do I need to install npm separately?
No. npm is bundled with the Node.js installer. After installing Node.js, npm is automatically available. You don’t need to do anything extra.
Can I install Node.js without admin rights?
Yes, but it’s more complex. You can download the portable ZIP version from nodejs.org, extract it to a folder like C:\Users\YourName\nodejs, and manually add that folder to your PATH. This works without admin rights but you won’t get the convenience of the installer’s automatic PATH setup.
What’s the difference between npm and npx?
npm is the package manager—it installs, updates, and removes packages. npx is a tool that comes with npm; it runs packages directly without installing them globally. For example, npx create-react-app my-app runs the create-react-app tool without permanently installing it.
Why do I get a “permission denied” error when running npm install -g?
On Windows, this usually means the Command Prompt isn’t running as Administrator. Right-click the Command Prompt and select “Run as administrator”. Alternatively, you can configure npm to use a user-level folder for global packages, but that’s more advanced.
How do I completely uninstall Node.js from Windows?
Use the “Apps & features” settings in Windows, find Node.js, and click Uninstall. Then manually delete the C:\Program Files\nodejs folder if it remains, and remove any leftover npm cache in %AppData%\npm and %AppData%\npm-cache if you want a clean slate.
Is Node.js safe to install?
Yes, if you download it from the official website nodejs.org. The installer is digitally signed by the Node.js Foundation. Always avoid third-party download sites that may bundle malware. After installation, keep it updated to receive security patches.
Related
General steps for current mainstream versions; menus can differ by device and version. See the disclaimer or report an error.
More in this bed
- How to Recover Deleted Voicemail on Android
- How to Limit Mobile Data Usage on Android
- View Shared Folder Permissions in Windows
- Check If a Game Is Installed on a Samsung Phone
- Error 0x80070522 Required Privilege Not Held: Fix
- How to Make a Family Tree in Excel