Was going through regular updates and got an error when trying to install PM2 that suggested to do it by command line but got this error
[Symfony\Component\Process\Exception\ProcessFailedException]
The command "runuser 'asterisk' -s '/bin/bash' -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 && exp
ort 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 && e
xport 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)
Working directory: /root
Output:
================
Error Output:
================
/var/www/html/admin/modules/pm2/node/node_modules/pm2/node_modules/shelljs/node_modules/glob/node_modules/minimatch/minimatch.js:4
const path = (() => { try { return require('path') } catch (e) {}})() || {
^
SyntaxError: Unexpected token )
at exports.runInThisContext (vm.js:73:16)
at Module._compile (module.js:443:25)
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)
at require (module.js:384:17)
at Object.<anonymous> (/var/www/html/admin/modules/pm2/node/node_modules/pm2/node_modules/shelljs/node_modules/glob/glob.js:44:17)
at Module._compile (module.js:460:26)
at Object.Module._extensions..js (module.js:478:10)
Then, if I do it through the web interface this is what goes into the log file
[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: 5779f23338cdda82e1a9b20b2c91dde3
[npm-cache] [INFO] [npm] cache exists
[npm-cache] [INFO] [npm] clearing installed dependencies at /var/www/html/admin/modules/pm2/node/node_modules
/home/asterisk/.node/lib/node_modules/npm-cache/node_modules/rimraf/rimraf.js:46
throw Error('glob dependency not found, set `options.disableGlob = true` i
^
Error: glob dependency not found, set `options.disableGlob = true` if intentional
at Error (native)
at defaults (/home/asterisk/.node/lib/node_modules/npm-cache/node_modules/rimraf/rimraf.js:46:11)
at Function.rimrafSync (/home/asterisk/.node/lib/node_modules/npm-cache/node_modules/rimraf/rimraf.js:272:3)
at Object.removeSync (/home/asterisk/.node/lib/node_modules/npm-cache/node_modules/fs-extra/lib/remove/index.js:4:17)
at CacheDependencyManager.installCachedDependencies (/home/asterisk/.node/lib/node_modules/npm-cache/cacheDependencyManagers/cacheDependencyManager.js:157:6)
at CacheDependencyManager.loadDependencies (/home/asterisk/.node/lib/node_modules/npm-cache/cacheDependencyManagers/cacheDependencyManager.js:229:10)
at startManager (/home/asterisk/.node/lib/node_modules/npm-cache/index.js:117:15)
at /home/asterisk/.node/lib/node_modules/npm-cache/node_modules/async/lib/async.js:181:20
at Object.async.forEachOf.async.eachOf (/home/asterisk/.node/lib/node_modules/npm-cache/node_modules/async/lib/async.js:233:13)
at Object.async.forEach.async.each (/home/asterisk/.node/lib/node_modules/npm-cache/node_modules/async/lib/async.js:209:22)
I had the same issue. That version of minimatch.js must be old. make a backup of the version in /var/www/html/admin/modules/pm2/node/node_modules/pm2/node_modules/shelljs/node_modules/glob/node_modules/minimatch/minimatch.js (copied from your post) and then do a file search and locate another version on the system. I copied the version from elsewhere and ran the command again and it worked. Unfortunately, I was just working through this a few days ago and I don’t remember where I copied it from. Just do a “find / -name minimatch.js” from the console and see where some other copies are. I remember doing a long ls (ls -l) and saw the date for this file as 1985, I think I found one that was newer and used that copy.
For the glob part, notice it is saying:
“clearing installed dependencies at /var/www/html/admin/modules/pm2/node/node_modules”
go to that path and delete any zip files (red in console). I discovered that glob is just for removing files, if you remove them manually, you can get past this issue. Just be careful about what you delete.
It looks like someone updated a dependency of a dependency of a dependency of PM2 (minimatch package) on the node side in a way that arguably breaks semvar. minimatch between 3.0.4 (previous version) and 3.0.5 (new version released 5 days ago) seem to be breaking for older versions of node.
I saw a couple of other people opened issues against the new version of the minimatch module here with similar issues:
We’re still trying to decide on how to handle it from a fix perspective. To be continued…
Ended up fixing this by removing the folder /home/asterisk/.pm2 and /home/asterisk/.package_cache and then installing again from console with fwconsole ma install pm2
Here are the command list
cd /home/asterisk/
mv .pm2 .pm2BAK
rm -rf .package_cache
fwconsole ma install pm2