Home  >  Article  >  Web Front-end  >  How to set up a Node.js environment in a Windows environment

How to set up a Node.js environment in a Windows environment

PHPz
PHPzOriginal
2023-04-05 13:47:49639browse

Node.js is a JavaScript runtime based on the Chrome V8 engine. It allows JavaScript to run on the server and directly in the operating system, making it a very popular back-end development language. To build a Node.js environment in a Windows environment, you need to go through the following steps:

Step 1: Download the Node.js installation package

The Node.js installation package can be found on the official website https: Download from //nodejs.org/en/download/. It is recommended to choose the LTS version for download. After the download is complete, run the installation package to install.

Step 2: Configure environment variables

After the installation is completed, you need to configure environment variables to execute Node.js on the Windows system and add the installation path of Node.js to the PATH variable. You can set environment variables through the following steps:

  1. Right-click "Computer" on the desktop and select "Properties" to enter the system properties page.
  2. Click "Advanced System Settings" on the left to enter the "System Properties" dialog box.
  3. Click "Environment Variables" to open the environment variables dialog box.
  4. In "System Variables", find the "Path" variable and click the "Edit" button.
  5. In the Edit Environment Variables dialog box, click the "New" button to add the installation path of Node.js.
  6. Click "OK" to close all dialog boxes.

If you have opened a command line window before, you need to restart it for the settings to take effect.

Step 3: Test Node.js installation

Enter the following command in the command line window:

node -v

If the version number of Node.js is output, the installation is successful.

Step 4: Install npm

npm is the package management tool for Node.js. You can easily install, upgrade, and delete Node.js modules through npm. Enter the following command in the command line window to install npm:

npm install -g npm

After the installation is complete, use the following command to verify the version number:

npm -v

If the npm version number is output, the installation is successful.

Step 5: Install common modules

In order to make the development of Node.js more convenient, you generally need to install some commonly used modules. Common modules can be installed through the following command:

npm install -g express nodemon mongoose

After the installation is complete, you can use these modules for development.

Summary:

The above are the steps to build a Node.js environment in a Windows environment. I believe that after the above steps, you can successfully build a Node.js development environment. In actual development, it is necessary to install corresponding modules and configure the development environment according to specific needs.

The above is the detailed content of How to set up a Node.js environment in a Windows environment. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn