0

enter image description hereI have updated my asp.net core API over linux server using kestrel, I want to run the core application using pm2. Let me know if any buddy has already done this kind of task.

What I have tried is:

  • I Installed the pm2 on my linux server (not globally). It installed successfully but when I'm trying to run the code using pm2, I am getting error pm2, command not found

  • I tried to install the pm2 globally but getting write access issue in node modules some where but I can't give global write access.

Thanks in advance for your help :)

jww
  • 97,681
  • 90
  • 411
  • 885
Parshant Dutta
  • 450
  • 1
  • 4
  • 12
  • How exactly did you install? Di you try to do `sudo npm install -g pm2`? – papanito Oct 18 '19 at 07:08
  • I have used following commands 1. sudo npm install pm2 i.e. particular directory 2. sudo npm install -g pm2 -g i.e. global installation – Parshant Dutta Oct 18 '19 at 07:13
  • When installing only for you, you may probably ensure that `~/node_modules/pm2/bin` is part of your `PATH` variable. Also checkout https://stackoverflow.com/a/41317809/229864 – papanito Oct 18 '19 at 07:17
  • papanito, please review the screenshot attached. I have tried to run command just now and getting the following error. Let me know if we can run server on particular directory instead of running globally. – Parshant Dutta Oct 18 '19 at 07:26
  • run `sudo npm i -g pm2` cause in the screenshot you are running it without `sudo`. or when you installed it locally try `~/node_modules/pm2/bin/pm2` or as mentioned add the bin path to your `PATH` variable – papanito Oct 18 '19 at 07:40

1 Answers1

0

pm2, command not found means the binary is not found cause it is most probably missing in your PATH variable. The path differs whether you install it globally or not - see pm2-command-not-found how to figure out the path and how to add it to your PATH variable.

When not installed globally, the binaries are under ~\node_modules. This you have to add the actual binary path e.g. ~/node_modules/pm2/bin to the PATH variable or you call it directly using ~/node_modules/pm2/bin/pm2

For the installation problem mentioned above, run the installation as sudo npm install -g pm2

papanito
  • 2,349
  • 2
  • 32
  • 60