Home > Web Front-end > JS Tutorial > Solve the problem that node.js global module cannot be found under Linux

Solve the problem that node.js global module cannot be found under Linux

php中世界最好的语言
Release: 2018-05-21 13:55:40
Original
1749 people have browsed it

This time I will bring you a solution to the problem that the global module cannot be found in node.js under linux, and a solution to the problem that the node.js global module under linux cannot be found. What are the precautions?What are the following? This is a practical case, let’s take a look at it.

Today I used npm to install on linux and prepared to deploy the node project. However, when I started the project through the pm2 command , it reported that pm2 could not be found. This is very sad. , thinking that pm2 was not installed successfully, but there was no problem calling pm2 in the bin folder under the node installation directory.

/usr/local/node/node-v7.3.0-linux-x64/bin/pm2 list
Copy after login

Similarly call the pm2 list command to view the projects started by pm2 without any problem.

It turns out that after the module is installed globally through npm on the Linux system, the environment

variables cannot be automatically configured like under Windows, and you need to configure it yourself. . . Well, do it yourself. . .

Configuring environment variables on Linux is very simple. You only need to modify the /etc/profile file. Just write the directory of the node module at the end of the profile file.

export NODE_HOME=/usr/local/node/node-v7.3.0-linux-x64/bin
export PATH=$NODE_HOME:$PATH
Copy after login
The NODE_HOME here is the bin directory in my node.js installation directory, so you don’t need to write the complete path every time you execute the global module command.

Note that after modifying the environment variables, you need to log out and then log in again to the server for it to take effect. I am using a cloud server. Just

exit the system and reconnect again, and then the modified configuration will take effect. .

Execute the command directly

pm2 list
Copy after login
It runs perfectly. . .

I believe you have mastered the method after reading the case in this article. For more exciting information, please pay attention to other related articles on the php Chinese website!

Recommended reading:

php Detailed explanation of steps to crop images to a fixed size


php generates random numbers, letters or numeric letters Mixed string

The above is the detailed content of Solve the problem that node.js global module cannot be found under Linux. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
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