Search code examples
linuxasp.net-corepm2

How to run asp.net core application using pm2 on linux server


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 :)


Solution

  • 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