Unable to update PM2 module

FreePBX Distro SNG7-PBX-64bit-2104-1
module Process Management pending upgrade from 5.0.4 to 15.0.8
update process fails (/var/www/html/admin/modules/pm2/node/logs/install.log)

in log see
npm WARN npm npm does not support Node.js v8.16.0
npm ERR! URL is not defined
npm ERR! /home/asterisk/.npm/_logs/2022-05-03T13_45_20_677Z-debug.log

in next log see:
warn npm npm does not support Node.js v8.16.0
info using [email protected]
info using [email protected]
error URL is not defined

Спойлер

0 warn npm npm does not support Node.js v8.16.0
1 warn npm You should probably upgrade to a newer version of node as we
2 warn npm can’t make any promises that npm will work with this version.
3 warn npm You can find the latest version at https://nodejs.org/
4 verbose cli [ ‘/usr/bin/node’,
4 verbose cli ‘/usr/bin/npm’,
4 verbose cli ‘install’,
4 verbose cli ‘–only=production’ ]
5 info using [email protected]
6 info using [email protected]
7 timing npm:load:whichnode Completed in 0ms
8 timing config:load:defaults Completed in 2ms
9 timing config:load:file:/usr/lib/node_modules/npm/npmrc Completed in 1ms
10 timing config:load:builtin Completed in 1ms
11 verbose config only Use --omit=dev to omit dev dependencies from the install.
12 timing config:load:cli Completed in 2ms
13 timing config:load:env Completed in 0ms
14 timing config:load:file:/var/www/html/admin/modules/pm2/node/.npmrc Completed in 0ms
15 timing config:load:project Completed in 1ms
16 timing config:load:file:/home/asterisk/.npmrc Completed in 0ms
17 timing config:load:user Completed in 0ms
18 timing config:load:file:/home/asterisk/.node/etc/npmrc Completed in 1ms
19 timing config:load:global Completed in 1ms
20 timing config:load:validate Completed in 0ms
21 timing config:load:credentials Completed in 1ms
22 timing config:load:setEnvs Completed in 0ms
23 timing config:load Completed in 8ms
24 timing npm:load:configload Completed in 9ms
25 timing npm:load:setTitle Completed in 0ms
26 timing npm:load:setupLog Completed in 0ms
27 timing config:load:flatten Completed in 2ms
28 timing npm:load:cleanupLog Completed in 2ms
29 timing npm:load:configScope Completed in 0ms
30 timing npm:load:projectScope Completed in 0ms
31 timing npm:load Completed in 15ms
32 timing arborist:ctor Completed in 1ms
33 timing arborist:ctor Completed in 0ms
34 timing idealTree:init Completed in 12ms
35 timing idealTree:userRequests Completed in 1ms
36 silly idealTree buildDeps
37 silly fetch manifest [email protected]
38 silly placeDep ROOT pm2@ Symbol(OK) for: [email protected] want: 4.5.0
39 timing idealTree:#root Completed in 7ms
40 timing idealTree:node_modules/pm2 Completed in 0ms
41 timing idealTree:buildDeps Completed in 7ms
42 timing idealTree:fixDepFlags Completed in 0ms
43 timing idealTree Completed in 21ms
44 timing command:install Completed in 39ms
45 verbose stack ReferenceError: URL is not defined
45 verbose stack at regKeyFromURI (/usr/lib/node_modules/npm/node_modules/npm-registry-fetch/auth.js:7:18)
45 verbose stack at getAuth (/usr/lib/node_modules/npm/node_modules/npm-registry-fetch/auth.js:49:18)
45 verbose stack at regFetch (/usr/lib/node_modules/npm/node_modules/npm-registry-fetch/index.js:55:16)
45 verbose stack at RegistryFetcher.packument (/usr/lib/node_modules/npm/node_modules/pacote/lib/registry.js:86:15)
45 verbose stack at RegistryFetcher.manifest (/usr/lib/node_modules/npm/node_modules/pacote/lib/registry.js:117:17)
45 verbose stack at Object.manifest (/usr/lib/node_modules/npm/node_modules/pacote/lib/index.js:16:45)
45 verbose stack at Arborist.[fetchManifest] (/usr/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/arborist/build-ideal-tree.js:1136:24)
45 verbose stack at Arborist.[nodeFromSpec] (/usr/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/arborist/build-ideal-tree.js:1154:29)
45 verbose stack at Arborist.[nodeFromEdge] (/usr/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/arborist/build-ideal-tree.js:997:44)
45 verbose stack at Arborist.[buildDepStep] (/usr/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/arborist/build-ideal-tree.js:877:36)
46 verbose cwd /var/www/html/admin/modules/pm2/node
47 verbose Linux 3.10.0-1127.19.1.el7.x86_64
48 verbose argv “/usr/bin/node” “/usr/bin/npm” “install” “–only=production”
49 verbose node v8.16.0
50 verbose npm v7.21.1
51 error URL is not defined
52 verbose exit 1

I tried all the suggestions from the threads on this forum, but nothing worked.
№1 №2 №3 №4 №5

> yum install npm
Package 1:npm-3.10.10-1.6.17.1.1.el7.x86_64 is obsoleted by 2:nodejs-8.16.0-1.11.x86_64 which is already installed
Nothing to do
> node -v
v8.16.0
> npm -v
npm WARN npm npm does not support Node.js v8.16.0
7.21.1

and try remove module

> rm -Rf /var/www/html/admin/modules/pm2
> fwconsole ma downloadinstall pm2
> curl -fsSL https://rpm.nodesource.com/setup_12.x | bash -
## Installing the NodeSource Node.js 12.x repo...
## Inspecting system...
+ rpm -q --whatprovides redhat-release || rpm -q --whatprovides centos-release || rpm -q --whatprovides cloudlinux-release || rpm -q --whatprovides sl-release || rpm -q --whatprovides fedora-release
+ uname -m
## You don't appear to be running a supported version of Enterprise Linux. Please contact NodeSource at https://github.com/nodesource/distributions/issues if you think this is incorrect or would like your architecture to be considered for support. Include your 'distribution package' name: sangoma-release-7-8.2003.3.el7.sangoma.x86_64.

nothing helps

tell me what to do?

Welcome to our Community forum.

At first, please don’t touch npm and don’t change its version please.

I assume your system is broken somewhere.
Anyway, you can try to update your system with yum update -y and fwconsole ma updateall

You did so many things that I don’t know if that will be worst or not.
Before update, try to downgrade npm to 6.4.1 and next uninstall pm2 and reinstall it.

I try downgrade npm, but error agane

npm install -g [email protected]
npm WARN npm npm does not support Node.js v8.16.0
npm WARN npm You should probably upgrade to a newer version of node as we
npm WARN npm can't make any promises that npm will work with this version.
npm WARN npm You can find the latest version at https://nodejs.org/
npm ERR! URL is not defined

npm ERR! A complete log of this run can be found in:
npm ERR!     /root/.npm/_logs/2022-05-04T05_41_53_417Z-debug.log

I assume that sometime npm was updated incorrectly

I found an old FreePBX VM with old npm 6.4.1, node v8.16.0, pm2 15.0.4 in it
Can I just copy the /usr/lib/node_modules/npm directory from vbox to the production server? Will it harm the server?

I don’t think so.
Try this:

One day I tested to update npm too and that was a bad idea :smiley:
Once installed the original version, everything worked fine again.

No, this is npm install -g npm@version_number dont work

> npm install -g [email protected]
npm WARN npm npm does not support Node.js v8.16.0
npm ERR! URL is not defined

I took a chance anyway and copied /usr/lib/node_modules/npm (version 6.4.1) to the production server and it worked.

also I do

> ln -s /usr/lib/ /usr/lib/node_modules/npm/package.json
> npm restart
> fwconsole ma downloadinstall pm2
Module pm2 version 15.0.10 successfully installed

No repos specified, using: [standard,extended] from last GUI settings

Downloading module ‘pm2’
Processing pm2
Verifying local module download…Verified
Extracting…Done
Download completed in 3 seconds
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
Running installation…
npm WARN deprecated [email protected]: Debug versions >=3.2.0 <3.2.7 || >=4 <4.3.1 have a low-severity ReDos regression when used in a Node.js environment. It is recommended you upgrade to 3.2.7 or 4.3.1. (ReDos Vulnerability Regression Visibility Notice · Issue #797 · debug-js/debug · GitHub)
npm WARN deprecated [email protected]: Please upgrade to version 7 or higher. Older versions may use Math.random() in certain circumstances, which is known to be problematic. See There’s Math.random(), and then there’s Math.random() · V8 for details.
npm notice created a lockfile as package-lock.json. You should commit this file.
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@~2.3.2 (node_modules/chokidar/node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for [email protected]: wanted {“os”:“darwin”,“arch”:“any”} (current: {“os”:“linux”,“arch”:“x64”})
npm WARN [email protected] requires a peer of bufferutil@^4.0.1 but none is installed. You must install peer dependencies yourself.
npm WARN [email protected] requires a peer of utf-8-validate@^5.0.2 but none is installed. You must install peer dependencies yourself.

added 210 packages from 200 contributors and audited 211 packages in 12.888s
found 8 vulnerabilities (3 moderate, 4 high, 1 critical)
run npm audit fix to fix them, or npm audit for details

Finished updating libraries!
Генерируется CSS…Завершено
Module pm2 version 15.0.10 successfully installed
Шаги по обновлению…Завершено
Chowning directories…Done

===========
I fight with this problem ± 3-4 days. I try upgrade npm, but need downgrade
Thank you very much fdanard for your help.

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.