No able to run pm2 on Windows server 2012
Asked Answered
X

5

7

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.

Xenophobe answered 26/1, 2017 at 11:37 Comment(0)
T
22

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

Thrust answered 21/12, 2018 at 12:9 Comment(1)
Just linking back github's issue. github.com/Unitech/pm2/issues/2566Topsoil
A
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.

Azral answered 26/1, 2017 at 11:41 Comment(1)
BTW I had it working on another user account on the same machine and it worked.Xenophobe
C
3

just install pm2 in global mode

npm install pm2 -g -s
Choking answered 13/11, 2019 at 0:18 Comment(0)
B
0

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

Bibliofilm answered 28/6, 2022 at 20:18 Comment(0)
B
-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.

Bismuthinite answered 18/5, 2022 at 12:23 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.