If you’re planning to develop websites, run JavaScript applications, or work with modern development tools on your Windows computer, installing Node.js and npm is an important first step. These tools allow you to execute JavaScript outside a web browser and manage the packages required by different projects.
You can install Node.js and npm on Windows using Command Prompt (CMD) with a simple command through Windows Package Manager, also known as winget.
In this guide, you’ll learn how to install Node.js and npm using CMD.
Install Node.js & npm on Windows Using CMD

To install Node.js and npm on Windows using Command Prompt, follow these steps:
- Open Command Prompt as an administrator on your Windows computer.
- Check whether winget is available by running winget –version.
- Install the Node.js Long-Term Support (LTS) version using winget install OpenJS.NodeJS.LTS.
- Allow the installation to complete and follow any on-screen instructions.
- Close and reopen Command Prompt to refresh the environment.
- Type node -v to check the installed Node.js version.
- Type npm -v to verify that npm is installed and working.
The quickest installation command is:
winget install OpenJS.NodeJS.LTS
This command installs the Node.js LTS package through Windows Package Manager. npm is distributed with Node.js, so you can generally use it after Node.js has been installed successfully.
Step 1: Open Command Prompt as an Administrator
The first step is to open CMD with the appropriate permissions. While some commands can run without administrator access, using an elevated Command Prompt can help avoid permission-related installation problems.
Click the Start button on your Windows computer and type Command Prompt in the search box. When the application appears, right-click it and select Run as administrator. If Windows displays a User Account Control prompt, select Yes if you have permission to continue.
Once Command Prompt opens, you’ll see a black window where you can enter commands.
The navigation path is:
Start > Search Command Prompt > Right-click Command Prompt > Run as administrator
You don’t need to change any folders manually at this stage. Keep the Command Prompt window open because you’ll use it for the remaining installation steps.
Step 2: Check Whether Windows Package Manager Is Available
Windows Package Manager, commonly called winget, lets you install supported applications directly from the command line. It can save you time because you don’t have to manually locate and download the Node.js installer.
To check whether winget is available, type the following command in CMD and press Enter:
winget –version
If winget is installed, Command Prompt will display its version number. This confirms that Windows can recognize the command.
For example, you might see output similar to:
v1.x.x
The exact version depends on your Windows configuration and the installed version of Windows Package Manager.
The navigation path is:
Command Prompt > Type winget –version > Press Enter > Check the version
If Windows displays a message saying that winget is not recognized, you may need to update Windows or install or update the App Installer component through a supported Microsoft distribution method. Don’t proceed with the Node.js installation command until winget is available, unless you choose an alternative installation method.
Step 3: Install Node.js LTS Using CMD
Now it’s time to install Node.js. For most beginners, the LTS version is a practical choice because it is intended for long-term support and is commonly used for development projects.
In the administrator Command Prompt window, enter the following command:
winget install OpenJS.NodeJS.LTS
Press Enter and wait while Windows Package Manager searches for the package and begins the installation.
Depending on your system, Windows may ask you to accept source agreements or confirm the installation. Read the displayed prompts and provide confirmation when required.
The navigation path is:
Command Prompt > Type winget install OpenJS.NodeJS.LTS > Press Enter > Confirm prompts > Wait for installation
The installation time depends on your internet speed, computer performance, and package manager activity. Avoid closing the Command Prompt window while the installation is running.
Once the process finishes, look for a message indicating that the package was installed successfully. If you receive an error, note the exact message because it can help identify whether the issue is related to permissions, package availability, or network connectivity.
Important: The command above installs the LTS package identified by Windows Package Manager. If you need a specific Node.js version for a project, check the project’s version requirements before proceeding.
Step 4: Close and Reopen Command Prompt
After Node.js has been installed, it’s a good idea to close Command Prompt and open it again. This allows a new CMD session to load updated environment variables, including the PATH entry that Windows uses to locate executable files.
If you continue using the same Command Prompt window, the newly installed commands may not be recognized immediately in some situations.
Close the current window by clicking the X button in the upper-right corner. Then open Command Prompt again through the Start menu.
The navigation path is:
Close Command Prompt > Start > Search CMD > Open Command Prompt
You don’t necessarily need to run CMD as an administrator to check the installation. A regular Command Prompt window is usually sufficient for verifying Node.js and npm.
Step 5: Check the Installed Node.js Version
Now that you’ve reopened Command Prompt, verify whether Node.js is available.
Type the following command:
node -v
Press Enter. If Node.js is installed correctly and its executable is available through PATH, CMD will display the installed version.
For example:
v22.x.x
The version number shown on your computer may be different, depending on the current LTS release and when you installed it.
The navigation path is:
Command Prompt > Type node -v > Press Enter > Read the Node.js version
The node -v command is a quick way to confirm that Windows can locate the Node.js executable. If you see a version number, Node.js is available from your current Command Prompt session.
If you receive the message ‘node’ is not recognized as an internal or external command, the installation may not have completed correctly, or your PATH environment variable may not have refreshed. In that situation, continue with the troubleshooting section below.
Step 6: Verify npm Installation
When Node.js is installed, npm is normally installed along with it. npm stands for Node Package Manager, and it helps developers install, update, and manage JavaScript packages for their projects.
To check whether npm is available, enter this command in CMD:
npm -v
Press Enter and check the version displayed in the terminal.
For example:
10.x.x
The exact npm version depends on the Node.js release included in your installation.
The navigation path is:
Command Prompt > Type npm -v > Press Enter > Check the npm version
If you see a version number, npm is accessible through Command Prompt. You can now use npm commands to manage project dependencies and run supported development scripts.
Remember that the npm version isn’t required to match the Node.js version. They use different versioning systems, so seeing different numbers is normal.
Step 7: Confirm Node.js and npm Are Working Together
Checking the version numbers is a useful first test, but you can also run a simple Node.js command to make sure the JavaScript runtime is functioning.
In Command Prompt, type:
node -e “console.log(‘Node.js is working’)”
Press Enter. If the installation is working, you should see:
Node.js is working
The node -e option allows you to execute a short JavaScript expression directly from CMD without creating a separate JavaScript file.
The navigation path is:
Command Prompt > Type node -e “console.log(‘Node.js is working’)” > Press Enter > Check the output
This is a simple test for beginners. It confirms that Node.js can execute JavaScript code from the command line.
You can also check npm’s command-line functionality by running:
npm –version
If both commands return version information and the JavaScript test displays the expected message, your installation is ready for basic use.
Step 8: Test npm With a Sample Project
After installing Node.js and npm, you may want to test npm by creating a small project folder. This step isn’t mandatory, but it helps you understand how npm works.
First, create a folder for testing:
mkdir node-test
Move into the folder:
cd node-test
Then initialize an npm project:
npm init -y
The npm init -y command creates a package.json file with default project information. This file is used to describe your Node.js project and its dependencies.
The navigation path is:
Command Prompt > mkdir node-test > cd node-test > npm init -y
If the command completes successfully, you should see a package.json file in the folder. You can open the folder using File Explorer to confirm that the file was created.
This test doesn’t install an additional package. It simply checks whether npm can initialize a project correctly.
Common Problems When Installing Node.js and npm
Node.js Is Not Recognized in CMD
If you see an error stating that node is not recognized, first close and reopen Command Prompt. This allows Windows to reload environment variables.
If the problem continues, check whether Node.js was installed successfully through winget. You can also inspect the Windows PATH settings and verify that the Node.js installation directory is included.
Avoid adding random directories to PATH. Use the actual installation location and make changes carefully.
npm Is Not Recognized After Node.js Installation
If node -v works but npm -v doesn’t, the npm installation or PATH configuration may need attention.
Start by reopening CMD and testing the commands again. If the issue remains, review the installation result and consider repairing or reinstalling Node.js through a supported installation method.
Winget Installation Fails
The winget command may fail because of package source issues, network problems, permissions, or an unavailable package. Read the error message displayed in CMD before trying another command.
You can check the package information with:
winget search Node.js
This helps you identify available Node.js packages in the configured package sources. Check the package name carefully before installing a different version.
FAQs
Can I Install Node.js and npm Without a Browser?
Yes. You can install Node.js and npm using winget in Command Prompt, provided that Windows Package Manager is available and can access the package source. The installation still requires an internet connection to download the package.
Is npm Installed Automatically With Node.js?
npm is normally distributed with Node.js, so installing Node.js through the official package generally provides npm as well. You can confirm its availability by running npm -v in CMD.
How Do I Update Node.js Using CMD?
You can use winget to check for available upgrades. First, run:
winget upgrade
Look for the Node.js package in the results. If an upgrade is available, you can use the relevant winget upgrade command after confirming the package identifier.
Can I Install a Specific Node.js Version?
Yes, but the exact command depends on the package versions available through winget and the version you need. If a project requires a particular Node.js version, check its documentation and use an appropriate version management approach.
How Do I Uninstall Node.js Using CMD?
You can use Windows Package Manager to uninstall the package. First, check the installed package details:
winget list Node.js
Then identify the appropriate package and use the corresponding uninstall command. Review the package name and identifier carefully before confirming the removal.
Bottom Lines
Installing Node.js and npm on Windows using CMD is a straightforward process when you use Windows Package Manager. The winget install OpenJS.NodeJS.LTS command provides a convenient way to install the Node.js LTS package without manually navigating through an installer.
After installation, always verify your setup using node -v and npm -v. These commands confirm whether Windows can access the installed tools. You can also run a short JavaScript test and initialize an npm project to make sure your development environment is ready.
Whether you’re learning JavaScript, working on a web application, or preparing to use a framework such as React, having Node.js and npm correctly installed gives you a foundation for your next project.