Closed daicheng123 closed 1 year ago
That’s a very old version of nvm. Can you try with the latest install command from the readme?
I have got same error with the latest (v0.39.1) version as well. When I'm trying with v14 the same command works fine but with v16 the result is:
npm ERR! command sh -c node postinstall
npm ERR! sh: node: command not found
@abmarko where are you trying that command?
I have a centos 7 build docker image which based on centos:7.9.2009. The nvm installed with the following lines:
curl https://raw.githubusercontent.com/creationix/nvm/v0.39.1/install.sh | bash; \
source ~/.bashrc; \
nvm install 10.24.1; \
npm install -g yarn@1.22.11; \
nvm install 12.22.12; \
npm install -g yarn@1.22.11; \
nvm install 14.19.1; \
npm install -g yarn@1.22.11; \
nvm install 16.15.0; \
npm install -g yarn@1.22.11; \
nvm install 18.0.0; \
npm install -g yarn@1.22.11; \
nvm alias default 16.15.0
After that inside the image I use for example the above mentioned sharp package:
npm install -g sharp
The error is the following:
npm ERR! code 127
npm ERR! path /root/.nvm/versions/node/v16.15.0/lib/node_modules/sharp
npm ERR! command failed
npm ERR! command sh -c (node install/libvips && node install/dll-copy && prebuild-install) || (node install/can-compile && node-gyp rebuild && node install/dll-copy)
npm ERR! sh: node: command not found
npm ERR! sh: node: command not found
npm ERR! A complete log of this run can be found in:
npm ERR! /root/.npm/_logs/2022-06-28T14_47_06_983Z-debug-0.log
I have another example but it's a private package install so you can't try it out:
npm ERR! code 127
npm ERR! path /root/.nvm/versions/node/v16.15.0/lib/node_modules/MY_PACKAGE_NAME/node_modules/spawn-sync
npm ERR! command failed
npm ERR! command sh -c node postinstall
npm ERR! sh: node: command not found
npm ERR! A complete log of this run can be found in:
npm ERR! /root/.npm/_logs/2022-06-28T14_49_05_905Z-debug-0.log
Inside the log files I found the same error:
381 verbose stack Error: command failed
381 verbose stack at ChildProcess.<anonymous> (/root/.nvm/versions/node/v16.15.0/lib/node_modules/npm/node_modules/@npmcli/promise-spawn/index.js:64:27)
381 verbose stack at ChildProcess.emit (node:events:527:28)
381 verbose stack at maybeClose (node:internal/child_process:1092:16)
381 verbose stack at Process.ChildProcess._handle.onexit (node:internal/child_process:302:5)
382 verbose pkgid sharp@0.30.7
Anyway I have a centos8 based docker image as well but the error is same.
@ljharb any news on this ticket? Thank you!
I encountered the same issue, and I found that, when you run nvm install
and npm install
as a non-root user, no error occurs.
$ docker run --rm --it centos:7 bash
# useradd -m -s /bin/bash -u 1000 docker
# su docker -
$ cd /home/docker
$ curl https://raw.githubusercontent.com/creationix/nvm/v0.39.1/install.sh | bash
$ source ~/.bashrc
$ nvm install 16
$ nvm use 16
$ npm install -g sharp
<no error>
I found that, install scripts are run as a non-root user, even if you run npm install
as a root user. I think probably this is related to this issue.
That’s just how npm works.
Hey Admin
when i use golobal install pnpm ,and then tell me node command not found, but when i use node version is ok. `
npm install -g @pnpm/exe
npm WARN config global --global
, --local
are deprecated. Use --location=global
instead.
npm ERR! code 127
npm ERR! path /root/.nvm/versions/node/v16.15.1/lib/node_modules/@pnpm/exe
npm ERR! command failed
npm ERR! command sh -c node setup.js
npm ERR! sh: node: command not found
npm ERR! A complete log of this run can be found in: npm ERR! /root/.npm/_logs/2023-11-09T09_32_16_659Z-debug-0.log
`
Closing, since the OP hasn’t responded.
If anyone is still having trouble, please file a new issue and fill out the issue template.
Operating system and version:
nvm debug
output:nvm ls
output:-> v16.15.0 *
default -> 10.21.0 (-> v10.21.0 *)
node -> stable (-> v16.15.0 *) (default)
stable -> 16.15 (-> v16.15.0 *) (default)
unstable -> N/A (default)
lts/* -> lts/gallium (-> v16.15.0 *)
lts/argon -> v4.9.1 (-> N/A)
lts/boron -> v6.17.1 (-> N/A)
lts/carbon -> v8.17.0 (-> N/A)
lts/dubnium -> v10.24.1 (-> N/A)
lts/erbium -> v12.22.12 (-> N/A)
lts/fermium -> v14.19.3 (-> N/A)
lts/gallium -> v16.15.0 *
```
How did you install
nvm
?What steps did you perform?
What happened?
I packaged the code through jenkins. When executing the npm install command, the following error was reported:
This is the dockerfile of the image corresponding to the container I use for packaging:
Here is the code snippet from my jenkins pipeline about packaging the project:
Is there anything in any of your profile files that modifies the
PATH
?my .bashrc