pm2: command not found on Ubuntu server 14.04

Created on 19 Mar 2015  路  10Comments  路  Source: Unitech/pm2

Node version installed v0.10.25

When installing npm install pm2 -g and run pm2 start server.js I get the following issue:

No command 'pm2' found, did you mean:
 Command 'pms' from package 'pms' (universe)
 Command 'pmw' from package 'pmw' (universe)
 Command 'wm2' from package 'wm2' (universe)
 Command 'pmk' from package 'pmk' (universe)
 Command 'fpm2' from package 'fpm2' (universe)
 Command 'pmi' from package 'powermanagement-interface' (universe)
 Command 'pom2' from package 'libpod-pom-perl' (universe)
 Command 'pm' from package 'powerman' (universe)
pm2: command not found

Any clue why I get this?

PS: I'm working as root.

Most helpful comment

...because PM2 is not in your path.

type:
npm config get prefix

Append "/bin" to whatever that result is,
Then add that to your path in /etc/environment

(then restart or type "source /etc/environment" for that to take effect)

All 10 comments

...because PM2 is not in your path.

type:
npm config get prefix

Append "/bin" to whatever that result is,
Then add that to your path in /etc/environment

(then restart or type "source /etc/environment" for that to take effect)

This can be closed

@klinquist could you explain this with commands? I tried this and it did not work

@marcusjwhelan run npm config get prefix. You will get something similar to:

/home/user/.npm-global

Take it and add /bin:

/home/user/.npm-global/bin

Run nano ~/.bashrc (Ubuntu) and add to the last line:

export PATH=$PATH:/home/user/.npm-global/bin

Save (Ctrl) + O), close (Ctrl + X) and run source ~/.bashrc.

@klinquist thanks, it worked for me.

@jesobreira clean and simple, thank you very much friend!

@jesobreira thanks, dude!

You want clean and simple? I'll give you clean and simple! Copy/paste:

echo "PATH=\$PATH:`npm config get prefix`/bin" >> ~/.bashrc
source ~/.bashrc

@jesussanzdev @LucasAsafe you are welcome! It's worth to mention that the original answer was posted by @klinquist and my answer was just to add verbosity to his solution. Kudos to him!

You want clean and simple? I'll give you clean and simple! Copy/paste:

echo "PATH=\$PATH:`npm config get prefix`/bin" >> ~/.bashrc
source ~/.bashrc

You saved my life!!!!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ldarren picture ldarren  路  3Comments

lefam picture lefam  路  3Comments

alexpts picture alexpts  路  3Comments

waygee picture waygee  路  4Comments

webchaz picture webchaz  路  3Comments