0

I have all the npm pacakages installed for a particular user (i.e) not root (/home/otheruser/*)

I am using monit to see whether to check the program is running. In this case its pm2, which is in

/home/otheruser/.nvm/versions/node/v5.2.0/bin/pm2

I cannot use pm2 even when I tried using the full path from other users in the terminal even with root user. It didnot gave any output or nothing happened there like below.

root@server:~$ /home/otheruser/.nvm/versions/node/v5.2.0/bin/pm2 list

whenever I run node modules with different users like

root@server:~$ /home/otheruser/.nvm/versions/node/v5.2.0/bin/forever -v
root@server:~$ /home/otheruser/.nvm/versions/node/v5.2.0/bin/db-migrate -v
root@server:~$ /home/otheruser/.nvm/versions/node/v5.2.0/bin/pm2 -v

And I get the below in the syslog

node[5791]: No AX.25 port data configured
node[5791]: No AX.25 port data configured
node[5791]: No AX.25 port data configured

How to get that working from other users

The Keeper
  • 141
  • 5

2 Answers2

0

nvm is not a real program. It's a bash function that gets loaded in the user's .profile, .bashrc, or ... so sudo doesn't automatically pick it up from the $PATH like most other programs.

You can create a symbolic link and then try to access it

sudo ln -s "/home/otheruser/.nvm/versions/node/v5.2.0/bin/pm2"        "/usr/local/bin"

asmath
  • 301
  • 1
  • 6
  • No this doesnt help. If I installed pm2 as a other user, it stores .pm2 records in /home/otheruser/.pm2, the problem is from root or some user, i cannot even run the pm2 by providing full path – The Keeper Jan 11 '21 at 06:40
0

You have to add the below in the environment variable of the logged user(root) in which you are trying to run pm2 command and then it will works

NVM_DIR="/home/otheruser/.nvm"
NVM_BIN="/home/otheruser/.nvm/versions/node/v15.5.1/bin"
PATH="/home/otheruser/.nvm/versions/node/v10.15.3/bin"

asmath
  • 301
  • 1
  • 6