织梦CMS - 轻松建站从此开始!

欧博ABG官网-欧博官方网址-会员登入

How to Install Node.js and NPM on Your Windows Sys

时间:2025-10-26 15:08来源: 作者:admin 点击: 13 次
Learn how to install Node.js and NPM on Windows. Click here for the step-by-step guide to run and test Node.js on Windows.

Node.js is a runtime environment that includes everything you need to execute a program written in . It's used for running scripts on servers to render content before it is delivered to a web browser.

Node Package Manager (NPM) is an application manager and repository for developing and sharing JavaScript code. It enables managing Node.js dependencies.

This guide shows several methods to install and test Node.js and NPM on Windows.

Tutorial on how to install, use, update and remove Node.JS and NPM (Node package manager)

Prerequisites

Note: To install Node.js on different operating systems, check out our guides:

Install Node.js and NPM on Windows via Node.js Installer

If you prefer using the GUI to install programs, Node.js has a downloadable installer on their official website. Follow the steps below to install Node.js and NPM on Windows via the installer.

Step 1: Download Node.js Installer

In a web browser, navigate to the Node.js Downloads page. Click the Windows Installer button to download the latest stable version with long-term support (LTS). The installer also includes the NPM package manager.

Node.js Windows installer download page

Node.js Windows installer download page

The file is saved in the Downloads folder by default.

Other versions of Node.js and NPM are available, so choose the appropriate one for your system and use case. Use the top tabs to switch from the LTS to the current version to test the newest features. If you are new to Node.js or don't need a specific version, choose LTS since it is tested and stable.

Step 2: Install Node.js and NPM

After downloading the installer, follow the steps below:

1. Launch the installer by double-clicking the downloaded file.

2. The Node.js Setup Wizard starts with the welcome screen.

Node.js setup wizard welcome screen

Node.js setup wizard welcome screen

Click Next to proceed.

4. Review the end-user license agreement and click the checkbox to accept the terms and conditions.

Node.js setup wizard end-user license agreement

Node.js setup wizard end-user license agreement

Click Next to continue.

5. The installer asks to choose the installation location.

Node.js setup wizard install location

Node.js setup wizard install location

Leave the default location for a standard installation and click Next to proceed.

6. Select components to include or remove from the installation. The default options install Node.js, NPM, corepack, online documentation shortcuts, and add the programs to PATH.

Node.js setup custom setup

Node.js setup custom setup

Customize the setup or click Next to accept the default values.

7. The following section shows the total required space for the installation and the available space on disk.

Node.js setup disk space requirements

Node.js setup disk space requirements

Click OK to proceed. Select a different disk or install fewer features if the installation does not allow proceeding.

8. Choose whether to install additional dependencies for compiling native modules. Some NPM modules compile from C/C++ and require additional tools to function correctly (Python, Visual Studio Build Tools, and Chocolatey).

Node.js setup tools for native modules

Node.js setup tools for native modules

If you use such modules, select the checkbox and click Next. The selection of this option starts an installation script after the Node.js installation is complete.

For a simple installation, skip this step and click Next to proceed.

7. Click the Install button to start the installation.

Node.js setup ready to install

Node.js setup ready to install

8. The installer prompts for administrator confirmation to make changes to the device.

Node.js install administrator changes

Node.js install administrator changes

Enter the administrator password if prompted and click Yes to continue.

9. The installation takes some time. When it is complete, the final screen shows a success message.

Node.js setup install finished

Node.js setup install finished

Click Finish to complete the installation and close the installer.

Note: If you selected to install native tools in step 8, closing the installer automatically starts a PowerShell script to install the listed tools.

Step 3: Verify Installation

To verify Node.js installed successfully, run the following command in a command prompt or PowerShell:

node -v

The command shows the Node.js version installed on your system. Use the following command to check for NPM:

npm -v

node -v and npm -v cmd output

node -v and npm -v cmd output

Note: If NPM is not recognized or properly installed, command prompt displays the following error message: npm: command not found. Check if NPM is added to path, or if there are multiple versions installed on the system.

Install Node.js and NPM on Windows via Chocolatey

Chocolatey is a Windows package manager. It can be used to install programs such as Node.js with NPM. Follow the steps below to install Node.js and NPM using Chocolatey.

Note: Chocolatey is not available on Windows by default. If you need to install it, follow our guide to install Chocolatey on Windows.

Step 1: Install Node.js and NPM

To run the installation command, do the following:

1. Open the command prompt as an administrator.

2. Run the following command to install Node.js and NPM:

choco install nodejs

choco install nodejs CMD output

choco install nodejs CMD output

When prompted to run the installation script, press y and Enter to continue the installation. Wait for the installation to complete before proceeding.

3. Reset environment variables to add Node.js and NPM to PATH. Use the following command:

refreshenv

refreshenv CMD output

refreshenv CMD output

The command resets the environment variables, which enables running both programs from the terminal.

Step 2: Verify Node.js and NPM installation

To verify that Node.js is installed correctly, run the following command in a new command prompt session:

node -v

Check the NPM installation with:

npm -v

Both commands display the program version.

Test Node.js Installation

There are several ways to test a Node.js installation. The simplest way is to create a Hello World JavaScript program and run it using Node.js:

1. Open a text editor or IDE.

2. Add the following code to the file:

console.log("Hello, world!")

The code is a simple program that prints "Hello, world!" to the console.

3. Save the script with a .js extension.

4. Run the program from an IDE to see the results. Alternatively, navigate to the directory where the file is located and use the following command:

node [file_name].js

node hello.js CMD output hello world

node hello.js CMD output hello world

The command prints the message to the console, indicating that the Node.js installation works successfully.

Conclusion

You should now be able to install the Node.js framework and the NPM package manager. You also wrote your first Node.js JavaScript program.

Next, see the differences between Yarn and NPM, two different Node.js package managers, or learn how to update NPM.

Was this article helpful?

(责任编辑:)
------分隔线----------------------------
发表评论
请自觉遵守互联网相关的政策法规,严禁发布色情、暴力、反动的言论。
评价:
表情:
用户名: 验证码:
发布者资料
查看详细资料 发送留言 加为好友 用户等级: 注册时间:2025-11-02 04:11 最后登录:2025-11-02 04:11
栏目列表
推荐内容