6

I installed pm2 on Windows server 2012

npm install pm2 -g

I closed my PowerShell and opened it again.

When I try to run pm2 it fails with this error

> pm2 list

pm2 : The term 'pm2' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the
spelling of the name, or if a path was included, verify that the path is correct and try again.
At line:1 char:1
+ pm2 list
+ ~~~
    + CategoryInfo          : ObjectNotFound: (pm2:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException

I noticed PM2_HOME was not set, so I set it to my .pm2 in my home directory, but that didn't help

Any pointers?

What is interesting, is that I have it working on another account on the same machine.

zabumba
  • 12,172
  • 16
  • 72
  • 129

5 Answers5

20

Had the same problem on one Windows 2012R2 server PM2 was working and the other one not. In the Environment there was no path to

C:\Users\USERNAME\AppData\Roaming\npm

After adding the path and a restart of the server PM2 was recognized in PowerShell and CMD.

There is no need to add PM2 path to the System variables.

enter image description here

Yoruba
  • 2,572
  • 22
  • 26
3

There is Bountysource fundraising to make PM2 compatible with Windows:

which means that currently it is not completely compatible.

See also this issue:

with this comment from Unitech:

PM2 is a production module, who should be mainly used on Linux servers. I haven't tried it on other platforms than Linux.

rsp
  • 107,747
  • 29
  • 201
  • 177
3

just install pm2 in global mode

npm install pm2 -g -s
Stephen Kennedy
  • 20,585
  • 22
  • 95
  • 108
Esteban Perez
  • 390
  • 3
  • 5
0

The issue can be resolved by adding the path of npm to the env setting. At least that did the trick for me.

Newtoxton
  • 186
  • 2
  • 7
-2

Here How to solve it:

  1. Select Start > All Programs > Windows PowerShell version > Windows PowerShell.
  2. Type only: Set-ExecutionPolicy Unrestricted

Try to execute again.

Ayoung
  • 23
  • 4