NPM Global Path is not set
If one installs a module with npm install -g
such as
npm install -g semantic-release
They will find when they run node,
# node
Welcome to Node.js v17.2.0.
Type ".help" for more information.
> require('semantic-release')
Uncaught Error: Cannot find module 'semantic-release'
Require stack:
- <repl>
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:999:19)
at require (node:internal/modules/cjs/helpers:102:18) {
code: 'MODULE_NOT_FOUND',
requireStack: [ '<repl>' ]
}
This is because they do NOT have NODE_PATH
set. This should probably be set by the npm
package such that installation sets the environmental variable
NODE_PATH=/usr/local/lib/node_modules/
For the shell, or at least on invocations to node. Otherwise, globally installed modules won't work with Alpine.