How to check the running status of Node.js in CentOS 7

PHPz
Release: 2023-04-05 09:48:36
Original
1200 people have browsed it

CentOS 7 is a popular version of the Linux operating system commonly used for server running. If you want to run Node.js applications on a CentOS 7 server, you need to make sure Node.js is installed and running correctly. Below are some useful commands for querying Node.js running status on CentOS 7.

Query whether Node.js is installed

On CentOS 7, you can use the following command to query whether Node.js is installed on the system:

node -v
Copy after login

If Node.js is already installed installed on your server, you will see the output version number, for example:

v14.17.6
Copy after login
Copy after login

Otherwise, you will see "bash: node: command not found" or similar error message, which indicates that Node.js Not Installed.

Install Node.js

If Node.js is not installed on CentOS 7, you can use the following command to install it:

Install Node.js v14.x

sudo yum install -y gcc-c++ make
curl -sL https://rpm.nodesource.com/setup_14.x | sudo bash -
sudo yum install -y nodejs
Copy after login

Install Node.js v16.x

sudo yum install -y gcc-c++ make
curl -sL https://rpm.nodesource.com/setup_16.x | sudo bash -
sudo yum install -y nodejs
Copy after login

After the installation is completed, you can execute the "node -v" command again. The output of the version number indicates that the installation is successful.

Query the Node.js runtime version

When you have determined that Node.js has been installed on the CentOS 7 server, you can query which version of Node.js is running:

node -p process.versions.node
Copy after login

The output is similar to:

v14.17.6
Copy after login
Copy after login

Query npm version

npm is the package manager for Node.js. If you want to check the npm version, you can use the following command:

npm -v
Copy after login

The output is similar to:

6.14.15
Copy after login

Conclusion

With the above command, you can easily query and install the complete operation of Node.js and npm on the CentOS 7 server. Keep in mind that version control and management of Node.js are important and can avoid many problems in production environments. Be sure to test new versions carefully before using them in production, and record your version history carefully. Also make sure you have mastered the basics of Node.js and follow best practices.

The above is the detailed content of How to check the running status of Node.js in CentOS 7. For more information, please follow other related articles on the PHP Chinese website!

source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!