I can not run pm2 for n8n

Hi, I tried to build n8n on pm2 like Run n8n as a Service with PM2

On server Debian 10 (buster)
But I have this issue:

$npm_config_user=root npm install pm2@latest -g
/usr/local/nvm/versions/node/v14.16.1/bin/pm2 -> /usr/local/nvm/versions/node/v14.16.1/lib/node_modules/pm2/bin/pm2
/usr/local/nvm/versions/node/v14.16.1/bin/pm2-dev -> /usr/local/nvm/versions/node/v14.16.1/lib/node_modules/pm2/bin
/pm2-dev
/usr/local/nvm/versions/node/v14.16.1/bin/pm2-docker -> /usr/local/nvm/versions/node/v14.16.1/lib/node_modules/pm2/
bin/pm2-docker
/usr/local/nvm/versions/node/v14.16.1/bin/pm2-runtime -> /usr/local/nvm/versions/node/v14.16.1/lib/node_modules/pm2
/bin/pm2-runtime
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@~2.3.1 (node_modules/pm2/node_modules/chokidar/node_module
s/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for [email protected]: wanted {"os":"darwin","arch"
:"any"} (current: {"os":"linux","arch":"x64"})
+ [email protected]
updated 1 package in 5.384s

$pm2 start n8n
bash: pm2: command not found

I tried to do like instruction above. Could you help me, please?

Hey @cmdntd987,

Are you installing npm as root? It should be installed as the user who will be running n8n.

See if that helps.

Tephlon

I 've done it. I use this command for this issue:
This is official of pm2 debian 10. You could update instructions.

Anyway, there is no need to update PATH

./node_modules/.bin/pm2 start /usr/local/nvm/versions/node/v14.16.1/bin/n8n

Most of the work that I’ve been doing with n8n and pm2 has been using either Raspian, Raspberry Pi OS, or Ubuntu. Most of these have been based on Debian 10 (aka buster) or Debian 11 (aka bullseye).

This is the first time that I have seen this issue. I’m wondering if it is specific to Debian 10 or specific to your installation. As you can see from my YouTube video, the installation goes very smoothly without explicit referencing of file paths.

You can also check out the specific commands that I use to perform complete n8n installs from a standard Debian-based system installation on GitHub. It’s possible that some of your n8n installation steps may be affecting how pm2 works.