Home >Web Front-end >JS Tutorial >How to deal with the node.js global module cannot be found under Linux
This time I will bring you how to deal with the problem that the global module cannot be found under linuxnode.jsHow to deal with the problem that the global module of node.js under linux cannot be foundWhat are the precautionsWhat 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
There is no problem calling the pm2 list command like this to view the projects started by pm2.
It turns out that after the module is installed globally through npm on the Linux system, the environment 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:$PATHThe 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 directlypm2 list
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:
How to use AngularJS to implement tab switchingHow to use Koa2 to develop WeChat 2D Scan the QR code to payThe above is the detailed content of How to deal with the node.js global module cannot be found under Linux. For more information, please follow other related articles on the PHP Chinese website!