The Module Named "pm2" is required

not trying to hijack but have similar issue,

PBX Firmware:10.13.66-20
PBX Service Pack:1.0.0.0

removed nodejs and re-installed nodejs,
tried PM2 on giu and on cli with same result;

Installed:
nodejs.x86_64 0:0.12.18-1nodesource.el6

Starting pm2 download…
Processing pm2
Verifying local module download…Verified
Extracting…Done
Module pm2 successfully downloaded
Installing/Updating Required Libraries. This may take a while…The following messages are ONLY FOR DEBUGGING. Ignore anything that says ‘WARN’ or is just a warning
Found npm-cache v0.6.5
Running installation…[npm-cache] [INFO] using /home/asterisk/.package_cache as cache directory
[npm-cache] [INFO] [composer] Dependency config file /var/www/html/admin/modules/pm2/node/composer.json does not exist. Skipping install
[npm-cache] [INFO] [npm] config file exists
[npm-cache] [INFO] [npm] cli exists
[npm-cache] [INFO] [npm] hash of /var/www/html/admin/modules/pm2/node/package.json: b84d380aaab5f619c0c9f4060cc86a0c
[npm-cache] [INFO] [npm] cache exists
[npm-cache] [INFO] [npm] clearing installed dependencies at /var/www/html/admin/modules/pm2/node/node_modules
[npm-cache] [INFO] [npm] …cleared
[npm-cache] [INFO] [npm] retrieving dependencies from /home/asterisk/.package_cache/npm/2.15.11/b84d380aaab5f619c0c9f4060cc86a0c.tar.gz
[npm-cache] [INFO] [bower] Dependency config file /var/www/html/admin/modules/pm2/node/bower.json does not exist. Skipping install
[npm-cache] [INFO] [npm] done extracting
[npm-cache] [INFO] successfully installed all dependencies

Finished updating libraries!

[Symfony\Component\Process\Exception\ProcessFailedException]
The command “runuser ‘asterisk’ -c 'cd /var/www/html/admin/modules/pm2/node
&& mkdir -p /home/asterisk/.pm2 && mkdir -p /var/www/html/admin/modules/pm
2/node/logs && export HOME=”/home/asterisk" && export PM2_HOME="/home/aster
isk/.pm2" && export ASTLOGDIR="/var/log/asterisk" && export ASTVARLIBDIR="/
var/lib/asterisk" && export PATH="$HOME/.node/bin:$PATH" && export NODE_PAT
H="$HOME/.node/lib/node_modules:$NODE_PATH" && export MANPATH="$HOME/.node/
share/man:$MANPATH" && /var/www/html/admin/modules/pm2/node/node_modules/pm
2/bin/pm2 ping’" failed.
Exit Code: 1(General error)
Output:

Error Output:

module.js:338
throw err;
^
Error: Cannot find module 'debug’
at Function.Module._resolveFilename (module.js:336:15)
at Function.Module._load (module.js:278:25)
at Module.require (module.js:365:17)
at require (module.js:384:17)
at Object. (/var/www/html/admin/modules/pm2/node/node_module
s/pm2/constants.js:7:14)
at Module._compile (module.js:460:26)
at Object.Module._extensions…js (module.js:478:10)
at Module.load (module.js:355:32)
at Function.Module._load (module.js:310:12)
at Module.require (module.js:365:17)

ma [-f|–force] [-d|–debug] [–edge] [–color] [–skipchown] [-e|–autoenable] [–skipdisabled] [–format="…"] [-R|–repo="…"] [-t|–tag="…"] [args1] … [argsN]

(also removed PM2 once or twice) pure distro no addons, no changes

Hello @able,

I stumbled on this problem with some of my servers. For some reason the nodejs modules are not downloaded with the rest of the PM2 module (especially the debug module). I guess it is a timeout of one of the HTTP servers somewhere in the way because many of my Freepbx servers are being upgraded fine with the PM2 module.

What I am doing to bypass this problem is just copying a working PM2 module directory from another server with SCP and then I am “installing” the PM2 module.

Let us assume that you have a working and updated PM2 module with an ip address of 1.1.1.1 and a non working Freepbx server with an ip address of 2.2.2.2

Here are the steps:

  1. Remove the PM2 module directory from the non working Freepbx (2.2.2.2)
    rm -rf /var/www/html/admin/modules/pm2

  2. Copy the working PM2 directory from 1.1.1.1 to 2.2.2.2
    scp -r /var/www/html/admin/modules/pm2 [email protected]:/var/www/html/admin/modules/

  3. Install the PM2 module on 2.2.2.2 after the copy of the working module
    fwconsole ma install pm2

  4. Upgrade the rest of the modules on 2.2.2.2
    fwconsole ma upgradeall

  5. Reload the Freepbx framework on 2.2.2.2
    fwconsole reload

  6. Restart the Freepbx framework
    fwconsole stop && fwconsole start

Thank you,

Daniel Friedman
Trixton LTD.

Daniel,

thanks for taking the time to write this all out, i tried this and made sure i had the same version server, but sadly the error is the same, it is only 1 of 8 machines doing this!
i may have to re-install that one!

Hello @able,

Did you copied a working pm2 directory? Can you share again your logs on just installing the pm2 module?
It sounds that you did not copied it correctly.

Thank you,

Daniel Friedman
Trixton LTD.

Daniel,

I deleted the exisint pm2 directory, than copied it from another servert to the one in question, changed ownership on the pm2 directory to aserisk and ran the install. reload, restart.
the error output is exactly the same as is the error message, hence my thought to re-install it, as this is a problem that may not be in the first place related to the PM2 module is working fine (debug is working fine, nodejs is fine, all tested)

Hello @able,

The debug module is independent and should be located in the pm2 directory. Maybe you are using the wrong freepbx framework version. Try this:

  1. yum -y update freepbx
  2. fwconsole ma upgradeall
  3. fwconsole reload

Then restart my previous instructions.

Thank you,

Daniel Friedman
Trixton LTD.

That won’t do anything for someone using the distro

Hello @tm1000,

Yes, I missed the part that he uses the distro. I stumbled on the exact problem with some of my servers and managed to bypass the problem by copying the pm2 directory from a working server and installing it manually as I stated in my previous post.

You know that you did not answered my problem of why is the node_modules directory is not downloaded with the pm2 module in my bug report. Do you have an idea of what might be the problem?

Thank you,

Daniel Friedman
Trixton LTD.

It’s not downloaded with the module because in some cases that folder is huge and in other cases it contains code that is compiled specifically for your system.

situation after removing, and getting it from yet another server;

[npm-cache] [INFO] successfully installed all dependencies

Finished updating libraries!

[Symfony\Component\Process\Exception\ProcessFailedException]
The command “runuser ‘asterisk’ -c 'cd /var/www/html/admin/modules/pm2/node && mkdir -p /home/asterisk/.pm2 && mkdir -p /var/www/html/admin/modules/pm2/node/logs && export HOME=”/home/
asterisk" && export PM2_HOME=“/home/asterisk/.pm2” && export ASTLOGDIR=“/var/log/asterisk” && export ASTVARLIBDIR=“/var/lib/asterisk” && export PATH=“$HOME/.node/bin:$PATH” && export N
ODE_PATH=“$HOME/.node/lib/node_modules:$NODE_PATH” && export MANPATH=“$HOME/.node/share/man:$MANPATH” && /var/www/html/admin/modules/pm2/node/node_modules/pm2/bin/pm2 ping’" failed.
Exit Code: 1(General error)
Output:

Error Output:

module.js:338
throw err;
^
Error: Cannot find module ‘debug’
at Function.Module._resolveFilename (module.js:336:15)
at Function.Module._load (module.js:278:25)
at Module.require (module.js:365:17)
at require (module.js:384:17)
at Object. (/var/www/html/admin/modules/pm2/node/node_modules/pm2/constants.js:7:14)
at Module._compile (module.js:460:26)
at Object.Module._extensions…js (module.js:478:10)
at Module.load (module.js:355:32)
at Function.Module._load (module.js:310:12)
at Module.require (module.js:365:17)

Hello @able,

the installation of the pm2 module cannot find the debug module.
please show me the directory listing of the node_modules of pm2:

ls -la /var/www/html/admin/modules/pm2/node/node_modules

Thank you,

Daniel Friedman
Trixton LTD.

Daniel, done a few more to prevent follow on :slight_smile:

drwxr-xr-x 5 asterisk asterisk 4096 Jul 6 10:45 .
drwxrwxr-x. 121 asterisk asterisk 4096 Jul 6 10:43 …
drwxr-xr-x 2 asterisk asterisk 4096 Jun 27 00:01 Console
-rw-r–r-- 1 asterisk asterisk 148 Apr 12 17:45 .gitattributes
drwxr-xr-x 3 asterisk asterisk 4096 Jun 27 00:01 i18n
-rw-r–r-- 1 asterisk asterisk 34520 Apr 12 17:45 LICENSE
-rw-r–r-- 1 asterisk asterisk 1913 Jun 27 00:01 module.sig
-rw-r–r-- 1 asterisk asterisk 1457 Jun 27 00:01 module.xml
drwxr-xr-x 4 asterisk asterisk 4096 Jul 3 11:41 node
-rw-r–r-- 1 asterisk asterisk 18836 Jun 27 00:01 Pm2.class.php
-rw-r–r-- 1 asterisk asterisk 1646 Apr 12 17:45 README.md

node:

drwxr-xr-x 4 asterisk asterisk 4096 Jul 3 11:41 .
drwxr-xr-x 5 asterisk asterisk 4096 Jul 6 10:45 …
drwxr-xr-x 2 asterisk asterisk 4096 Jul 3 11:41 logs
drwxr-xr-x 4 asterisk asterisk 4096 Apr 24 14:37 node_modules
-rw-r–r-- 1 asterisk asterisk 187 Apr 12 17:45 package.json

node_modules:

drwxr-xr-x 4 asterisk asterisk 4096 Apr 24 14:37 .
drwxr-xr-x 4 asterisk asterisk 4096 Jul 3 11:41 …
drwxr-xr-x 2 asterisk asterisk 4096 Apr 24 14:37 .bin
drwxr-xr-x 5 asterisk asterisk 4096 Jul 3 11:41 pm2

pm2

drwxr-xr-x 5 asterisk asterisk 4096 Jul 3 11:41 .
drwxr-xr-x 4 asterisk asterisk 4096 Apr 24 14:37 …
-rw-r–r-- 1 asterisk asterisk 7137 Apr 16 16:16 ADVANCED_README.md
drwxr-xr-x 2 asterisk asterisk 4096 Jul 3 11:41 bin
-rw-r–r-- 1 asterisk asterisk 34355 Apr 16 16:16 CHANGELOG.md
-rw-r–r-- 1 asterisk asterisk 3933 Apr 16 16:16 constants.js
-rw-r–r-- 1 asterisk asterisk 1563 Apr 16 16:16 CONTRIBUTING.md
-rw-r–r-- 1 asterisk asterisk 12 Apr 16 16:16 .gitattributes
-rw-r–r-- 1 asterisk asterisk 34516 Apr 16 16:16 GNU-AGPL-3.0.txt
-rw-r–r-- 1 asterisk asterisk 298 Apr 16 16:16 index.js
drwxr-xr-x 7 asterisk asterisk 4096 Jul 3 11:41 lib
-rw-r–r-- 1 asterisk asterisk 17 Apr 16 16:16 LICENSE
-rw-r–r-- 1 asterisk asterisk 633 Apr 16 16:16 Makefile
drwxr-xr-x 28 asterisk asterisk 4096 Jul 3 11:41 node_modules
-rw-r–r-- 1 asterisk asterisk 145 Apr 16 16:16 .npmignore
-rw-r–r-- 1 asterisk asterisk 4295 Apr 24 14:37 package.json
-rw-r–r-- 1 asterisk asterisk 2418 Apr 16 16:16 paths.js
-rw-r–r-- 1 asterisk asterisk 10311 Apr 16 16:16 README.md
-rw-r–r-- 1 asterisk asterisk 272 Apr 16 16:16 .travis.yml

node_modules:

drwxr-xr-x 28 asterisk asterisk 4096 Jul 3 11:41 .
drwxr-xr-x 5 asterisk asterisk 4096 Jul 3 11:41 …
drwxr-xr-x 4 asterisk asterisk 4096 Jul 3 11:41 async
drwxr-xr-x 2 asterisk asterisk 4096 Jul 3 11:41 .bin
drwxr-xr-x 8 asterisk asterisk 4096 Jul 3 11:41 blessed
drwxr-xr-x 3 asterisk asterisk 4096 Jul 3 11:41 chalk
drwxr-xr-x 4 asterisk asterisk 4096 Jul 3 11:41 chokidar
drwxr-xr-x 4 asterisk asterisk 4096 Jul 3 11:41 cli-table
drwxr-xr-x 3 asterisk asterisk 4096 Jul 3 11:41 commander
drwxr-xr-x 5 asterisk asterisk 4096 Jul 3 11:41 cron
drwxr-xr-x 4 asterisk asterisk 4096 Jul 3 11:41 debug
drwxr-xr-x 3 asterisk asterisk 4096 Jul 3 11:41 eventemitter2
drwxr-xr-x 5 asterisk asterisk 4096 Jul 3 11:41 fclone
drwxr-xr-x 6 asterisk asterisk 4096 Jul 3 11:41 mkdirp
drwxr-xr-x 5 asterisk asterisk 4096 Jul 3 11:41 moment
drwxr-xr-x 6 asterisk asterisk 4096 Jul 3 11:41 nssocket
drwxr-xr-x 4 asterisk asterisk 4096 Jul 3 11:41 pidusage
drwxr-xr-x 5 asterisk asterisk 4096 Jul 3 11:41 pm2-axon
drwxr-xr-x 4 asterisk asterisk 4096 Jul 3 11:41 pm2-axon-rpc
drwxr-xr-x 3 asterisk asterisk 4096 Jul 3 11:41 pm2-deploy
drwxr-xr-x 5 asterisk asterisk 4096 Jul 3 11:41 pm2-multimeter
drwxr-xr-x 4 asterisk asterisk 4096 Jul 3 11:41 pmx
drwxr-xr-x 3 asterisk asterisk 4096 Jul 3 11:41 semver
drwxr-xr-x 5 asterisk asterisk 4096 Jul 3 11:41 shelljs
drwxr-xr-x 3 asterisk asterisk 4096 Jul 3 11:41 source-map-support
drwxr-xr-x 6 asterisk asterisk 4096 Jul 3 11:41 sprintf-js
drwxr-xr-x 4 asterisk asterisk 4096 Jul 3 11:41 vizion
drwxr-xr-x 10 asterisk asterisk 4096 Jul 3 11:41 yamljs

Hello @able,

let us clear the cache and try to reinstall again:

  1. yum -y upgrade npm
  2. fwconsole ma delete pm2
  3. fwocnsole reload
  4. rm -rf /var/www/html/admin/modules/pm2
  5. copy the working pm2 directory to the faulted server (scp -r)
  6. chown -R asterisk.asterisk /var/www/html/admin/modules/pm2
  7. fwconsole ma install pm2
  8. fwconsole reload

Thank you,

Daniel Friedman
Trixton LTD.

ok tried in several different ways and it simply cmes back with the same error as above in every which way.

went as far as to get rid of zulu xmpp and sangomacrm tried to reinstall from gui, no go same error, removed and cli installed, same error, removed downloaded from working server, installed, same error.

Yea, I still have a broken FreePBX server. If I do a command line “fwconsole ma downloadinstall pm2”, I get the following output:

[root@freepbx ~]# fwconsole ma downloadinstall pm2
No repos specified, using: [standard,commercial,extended] from last GUI settings

Starting pm2 download…
Processing pm2
Verifying local module download…Verified
Extracting…Done
Module pm2 successfully downloaded
Installing/Updating Required Libraries. This may take a while…The following messages are ONLY FOR DEBUGGING. Ignore anything that says ‘WARN’ or is just a warning
Found npm-cache v0.6.5
Running installation…[npm-cache] [INFO] using /home/asterisk/.package_cache as cache directory
[npm-cache] [INFO] [composer] Dependency config file /var/www/html/admin/modules/pm2/node/composer.json does not exist. Skipping install
[npm-cache] [INFO] [npm] config file exists
[npm-cache] [INFO] [npm] cli exists
[npm-cache] [INFO] [npm] hash of /var/www/html/admin/modules/pm2/node/package.json: b84d380aaab5f619c0c9f4060cc86a0c
[npm-cache] [INFO] [npm] cache exists
[npm-cache] [INFO] [npm] clearing installed dependencies at /var/www/html/admin/modules/pm2/node/node_modules
[npm-cache] [INFO] [npm] …cleared
[npm-cache] [INFO] [npm] retrieving dependencies from /home/asterisk/.package_cache/npm/2.15.11/b84d380aaab5f619c0c9f4060cc86a0c.tar.gz
[npm-cache] [INFO] [bower] Dependency config file /var/www/html/admin/modules/pm2/node/bower.json does not exist. Skipping install
[npm-cache] [INFO] [npm] done extracting
[npm-cache] [INFO] successfully installed all dependencies

Finished updating libraries!

[Symfony\Component\Process\Exception\ProcessTimedOutException]
The process “runuser ‘asterisk’ -c 'cd /var/www/html/admin/modules/pm2/node && mkdir -p /home/asterisk/.pm2 && mkdir -p /var/www/html/admin/modules/pm2/node/logs && expor
t HOME=”/home/asterisk" && export PM2_HOME="/home/asterisk/.pm2" && export ASTLOGDIR="/var/log/asterisk" && export ASTVARLIBDIR="/var/lib/asterisk" && export PATH="$HOME/
.node/bin:$PATH" && export NODE_PATH="$HOME/.node/lib/node_modules:$NODE_PATH" && export MANPATH="$HOME/.node/share/man:$MANPATH" && /var/www/html/admin/modules/pm2/node/
node_modules/pm2/bin/pm2 update’" exceeded the timeout of 60 seconds.

ma [-f|–force] [-d|–debug] [–edge] [–color] [–skipchown] [-e|–autoenable] [–skipdisabled] [–format="…"] [-R|–repo="…"] [-t|–tag="…"] [args1] … [argsN]

I had a few similar errors. I had to:

  1. Use yum to upgrade my nodejs from the command line (I had an older version installed)
  2. Run npm install from the /var/www/html/admin/modules/pm2/node/node_modules/pm2 directory (not /var/www/html/admin/modules/pm2!)
    After I did those steps the PM2 module installed without error.
1 Like

Hi,

i have here the same problem on one machine, running 10.13.66-20.

i tried the recommendation with copy over /var/www/html/admin/modules/pm2 from a working box.
it seems there a timeframe when you start
fwconsole ma install pm2
i tried it 3x until it got installed.
Then i ran fwconsole ma upgradeall
which upgraded the packages.
but after login the webconsole there was errors about tampered pm2 files
Also there was several errors about missing files pm2/node??/bin/pm2

so i ran
fwconsole ma refreshsignatures
which cleared out the pm2 directory again and has an other content.

i am unsure how to get the modules up and running correctly.

Also i am wondering, what is the reason, as there are several different machines and only some seems to have the problem.
Could it be there’s diskspaceproblem, from mongodb?
Cause i am running with a 10GB disk, where i have only 1.7GB free.

greets
Thomas

I am having the same issue for a Raspberry Pi OS Bullseye (based on Debian 11) setup.

All the installation steps applied for Asterisk 16 (detailled version: Asterisk 16.16.1~dfsg-1+deb11u1) and FreePBX 16 (detailled version: 16.0.10.33) worked fine up to the point where I am getting a complain for the installation of the PM2 module.

Here is the output when manually launching the respective commands on the shell prompt:

pi@raspberrypi: $ sudo apt install nodejs
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
nodejs is already the newest version (12.22.5~dfsg-2~11u1).
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
pi@raspberrypi: $ node -v
v12.22.5
pi@raspberrypi: $ sudo fwconsole ma install pm2
sh: 1: npm: not found
Node Package Manager is not installed
Unable to install module pm2:
 - Failed to run installation scripts
Updating Hooks...Done
Chowning directories...Done

From above I read that “npm” cannot be found, and, as such, the installation script fails.

So I went further, and have created the “npm” file with a symbolic link to “node” as outlined with:

ln -s /usr/bin/node /usr/bin/npm

Though, when manually running the installation of the PM2 module, I am getting the following output:

pi@raspberrypi: $ sudo fwconsole ma install pm2
NPM version is: v12.22.5 requirement is 2.15.11. Run 'yum upgrade nodejs' from the CLI as root
Unable to install module pm2:
 - Failed to run installation scripts
Updating Hooks...Done
Chowning directories...Done

Now, I’m stranded…

for context, its considered bad manners to repoen a thread from 2017 to tack on something like this…
I’d recommend opening a new thread for your specific issues.

But… the log literally tells you what to do…
Run 'yum upgrade nodejs' from the CLI as root

But as you are using Debian, apt install npm might work better.