Home  >  Article  >  Web Front-end  >  How to install global nodejs

How to install global nodejs

PHPz
PHPzOriginal
2023-04-05 09:09:012382browse

Node.js is a cross-platform JS runtime environment that allows developers to write server-side scripts using JavaScript. Installing Node.js globally allows users to run Node.js commands in any directory of the system. Next we will introduce how to install global Node.js under different operating systems.

1. Install global Node.js in Windows environment

1. Open the official website of Node.js (https://nodejs.org) and download the Windows version of Node.js installer .

2. Run the downloaded installation program and follow the instructions of the installation program to complete the installation.

3. After the installation is complete, enter the command "node -v" in the command prompt and press Enter. If the system can correctly output the version number of Node.js, it means that Node.js has been successfully installed and has been added to the system's environment variables.

2. Install global Node.js in MacOS environment

1. Use Homebrew to install Node.js, open the terminal and enter the following command:

brew install node

2. After the installation is completed, enter the command "node -v" in the terminal and press Enter. If the system can correctly output the version number of Node.js, it means that Node.js has been successfully installed and added to the system. environment variables.

3. Install global Node.js in Linux environment

1. Open the terminal and use command line installation tools (such as apt-get, yum) to install Node.js.

2. Enter the following command in the terminal:

sudo apt-get update

sudo apt-get install nodejs

3. Wait for the installation to complete , enter the command "node -v" in the terminal and press Enter. If the system can correctly output the version number of Node.js, it means that Node.js has been successfully installed and added to the system's environment variables.

4. Test the global Node.js installation under different operating systems

1. Open the terminal, enter the command "node -v" and press Enter.

2. The version number of the installed Node.js should be output in the terminal.

3. Enter the command "npm -v" and press Enter. If the system can correctly output the Npm version number, it means that Npm has been successfully installed and added to the system's environment variables.

4. At this point, the global Node.js installation is completed.

Summary

To install global Node.js, you need to choose the appropriate installation method according to different operating systems. After completing the installation, you need to enter the command in the terminal to test whether the installation is successful. After the preliminary preparation work is completed, developers can happily start using Node.js to write server-side scripts.

The above is the detailed content of How to install global nodejs. 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