nvm
nvm copied to clipboard
npm ERR! sh: node: command not found
Operating system and version:
nvm debug
output:
nvm --version: v0.34.0
$SHELL: /bin/bash
$SHLVL: 1
$HOME: /root
$NVM_DIR: '$HOME/.nvm'
$PATH: $NVM_DIR/versions/node/v10.21.0/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
$PREFIX: ''
$NPM_CONFIG_PREFIX: ''
$NVM_NODEJS_ORG_MIRROR: ''
$NVM_IOJS_ORG_MIRROR: ''
shell version: 'GNU bash, version 4.4.20(1)-release (x86_64-pc-linux-gnu)'
uname -a: 'Linux 5.4.172-90.336.amzn2.x86_64 #1 SMP Wed Jan 19 23:08:01 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux'
OS version: Ubuntu 18.04.6 LTS
curl: /usr/bin/curl, curl 7.58.0 (x86_64-pc-linux-gnu) libcurl/7.58.0 OpenSSL/1.1.1 zlib/1.2.11 libidn2/2.0.4 libpsl/0.19.1 (+libidn2/2.0.4) nghttp2/1.30.0 librtmp/2.3
wget: not found
git: not found
grep: /bin/grep (grep --color=auto), grep (GNU grep) 3.1
awk: not an option: --version
awk: /usr/bin/awk,
sed: /bin/sed, sed (GNU sed) 4.4
cut: /usr/bin/cut, cut (GNU coreutils) 8.28
basename: /usr/bin/basename, basename (GNU coreutils) 8.28
rm: /bin/rm, rm (GNU coreutils) 8.28
mkdir: /bin/mkdir, mkdir (GNU coreutils) 8.28
xargs: /usr/bin/xargs, xargs (GNU findutils) 4.7.0-git
nvm current: v10.21.0
which node: $NVM_DIR/versions/node/v10.21.0/bin/node
which iojs:
which npm: $NVM_DIR/versions/node/v10.21.0/bin/npm
npm config get prefix: $NVM_DIR/versions/node/v10.21.0
npm root -g: $NVM_DIR/versions/node/v10.21.0/lib/node_modules
nvm ls
output:
v10.21.0 * <br >
-> v16.15.0 * <br >
default -> 10.21.0 (-> v10.21.0 *) <br >
node -> stable (-> v16.15.0 *) (default) <br >
stable -> 16.15 (-> v16.15.0 *) (default) <br >
unstable -> N/A (default) <br >
lts/* -> lts/gallium (-> v16.15.0 *) <br >
lts/argon -> v4.9.1 (-> N/A) <br >
lts/boron -> v6.17.1 (-> N/A) <br >
lts/carbon -> v8.17.0 (-> N/A) <br >
lts/dubnium -> v10.24.1 (-> N/A) <br >
lts/erbium -> v12.22.12 (-> N/A) <br >
lts/fermium -> v14.19.3 (-> N/A) <br >
lts/gallium -> v16.15.0 * <br >
How did you install nvm
?
curl --silent -o- https://raw.githubusercontent.com/creationix/nvm/v0.34.0/install.sh | bash
What steps did you perform?
nvm use v16
npm install
What happened?
I packaged the code through jenkins. When executing the npm install command, the following error was reported:
...........
+ npm install
npm WARN old lockfile
npm WARN old lockfile The package-lock.json file was created with an old version of npm,
npm WARN old lockfile so supplemental metadata must be fetched from the registry.
npm WARN old lockfile
npm WARN old lockfile This is a one-time fix-up, please be patient...
npm WARN old lockfile
npm ERR! code 127
npm ERR! path /home/jenkins/agent/workspace/wholee-m_feature_dayu/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-05-19T09_35_22_296Z-debug-0.log
..........
This is the dockerfile of the image corresponding to the container I use for packaging:
FROM ubuntu:18.04
ENV NODE_VERSION 10.21.0
ENV NVM_DIR /root/.nvm
WORKDIR /root
COPY ./config .aws/
COPY ./credentials .aws/
WORKDIR $NVM_DIR
RUN rm /bin/sh && ln -s /bin/bash /bin/sh \
&& apt-get update \
&& apt-get -y install curl unzip python \
&& curl --silent -o- https://raw.githubusercontent.com/creationix/nvm/v0.34.0/install.sh | bash
RUN curl https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip -o awscliv2.zip \
&& unzip awscliv2.zip \
&& ./aws/install \
&& rm -rf aws awscliv2.zip
RUN source $NVM_DIR/nvm.sh \
&& nvm alias default $NODE_VERSION \
&& nvm use default
ENTRYPOINT ["/bin/bash"]
Here is the code snippet from my jenkins pipeline about packaging the project:
echo "--- start build ----"
ls -al *.tar.gz && echo 'removing previous archived tgz files'
rm -f *.tar.gz && echo "remove previous archived files..."
export BUILD_ENV=test
export CC=$HOME/library/clang-6.0.1/bin/clang
export CXX=$HOME/library/clang-6.0.1/bin/clang++
export LD_LIBRARY_PATH=$HOME/library/clang-6.0.1/lib:$LD_LIBRARY_PATH
source "$HOME/.nvm/nvm.sh"
if ! nvm which v16;then
nvm install v16
fi
nvm use v16
echo "--- start npm install ---"
which node
npm install
echo "--- startnpm run build test ---"
npm run build:test
if [[ $? != 0 ]]; then
nvm use default
exit -1
fi
nvm use default
echo '--- start wholee-mailbox compression ---'
cd dist
if [[ "false" == "true" && "" != "" ]];then
echo '' | sed 's/,/\n/g' | xargs -I{} mkdir -p _zone/{}/
echo '' | sed 's/,/\n/g' | xargs -I{} cp index.html _zone/{}/
fi
Is there anything in any of your profile files that modifies the PATH
?
my .bashrc
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion
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 [email protected]; \
nvm install 12.22.12; \
npm install -g [email protected]; \
nvm install 14.19.1; \
npm install -g [email protected]; \
nvm install 16.15.0; \
npm install -g [email protected]; \
nvm install 18.0.0; \
npm install -g [email protected]; \
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 [email protected]
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.