简体   繁体   中英

No able to run pm2 on Windows server 2012

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.

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.

在此处输入图像描述

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.

只需在全局模式下安装 pm2

npm install pm2 -g -s

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

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM