Issue
End clients can't successfully deploy Node.js applications, and when hitting the "Run NPM install" button, this error is displayed:
node:internal/modules/cjs/loader:933 const err = new Error(message);
Error: Cannot find module 'semver'Require stack:
- /opt/alt/alt-nodejs16/root/usr/lib/node_modules/npm/lib/utils/unsupported.js
- /opt/alt/alt-nodejs16/root/usr/lib/node_modules/npm/lib/cli.js
- /opt/alt/alt-nodejs16/root/usr/lib/node_modules/npm/bin/npm-cli.js
at Function.Module._resolveFilename (node:internal/modules/cjs/loader:933:15)
at Function.Module._load (node:internal/modules/cjs/loader:778:27)
at Module.require (node:internal/modules/cjs/loader:1005:19)
at require (node:internal/modules/cjs/helpers:102:18)
at Object. (/opt/alt/alt-nodejs16/root/usr/lib/node_modules/npm/lib/utils/unsupported.js:2:16)
at Module._compile (node:internal/modules/cjs/loader:1105:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1159:10)
at Module.load (node:internal/modules/cjs/loader:981:32)
at Function.Module._load (node:internal/modules/cjs/loader:822:12)
at Module.require (node:internal/modules/cjs/loader:1005:19) { code: 'MODULE_NOT_FOUND', requireStack: [ '/opt/alt/alt-nodejs16/root/usr/lib/node_modules/npm/lib/utils/unsupported.js', '/opt/alt/alt-nodejs16/root/usr/lib/node_modules/npm/lib/cli.js', '/opt/alt/alt-nodejs16/root/usr/lib/node_modules/npm/bin/npm-cli.js' ]}
Another symptom is the inability of reinstalling the npm package via yum/dnf:
# yum reinstall -y alt-nodejs16-npm
...
Installing : alt-nodejs16-npm-8.5.5-16.15.0.1.el7.x86_64 1/1
Error unpacking rpm package alt-nodejs16-npm-8.5.5-16.15.0.1.el7.x86_64
error: unpacking of archive failed on file /opt/alt/alt-nodejs16/root/usr/lib/node_modules/npm/node_modules/@npmcli: cpio: rename
Verifying : alt-nodejs16-npm-8.5.5-16.15.0.1.el7.x86_64 1/1
Failed:
alt-nodejs16-npm.x86_64 0:8.5.5-16.15.0.1.el7
Environment
- CloudLinux OS
- Node.js Selector
- NPM
Solution
The solution is to reinstall NPM completely:
# rpm -e --nodeps --justdb alt-nodejsXX-npm
# mv /opt/alt/alt-nodejsXX/root/usr/lib/node_modules{,.bk}
# yum install -y alt-nodejsXX-npm
Note: change "XX" for the appropriate Node.js version.
Cause
The issue usually presents itself when we install modules not available as rpm packages via NPM, which are not supported. Some symbolic links in the /opt/alt/alt-nodejsXX/root/usr/lib/node_modules
directory might have been changed into directories. This is the reason why this directory was moved in the previous step, to recreate it from scratch.
Useful links
- https://access.redhat.com/solutions/4278551
- https://docs.cloudlinux.com/cloudlinux_os_components/#node-js-deployment
Comments
0 comments
Please sign in to leave a comment.