Skip to content

The current version of nvm look for node distribution file which is not present and older version of nvm do find and install node but that does not work #3503

@rguptak

Description

@rguptak

Operating system and version:

Operating System: Alpine Linux v3.21 (containerized)

nvm debug output:

I do not get to the debug

nvm ls output:

How did you install nvm?

What steps did you perform?

Install necessary packages

RUN addgroup -S node && adduser -S node -s /bin/sh -D node && apk update && apk add --no-cache
ca-certificates
curl
bash
wget
git
nmap
openssh
html-xml-utils
jq
python3
python3-dev \
make
openssh-client

Install NVM

RUN curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.1/install.sh | bash

Modify PATH to include NVM

ENV PATH="/root/.nvm/versions/node/$(nvm version)bin:$PATH"

Install the latest Node.js version using NVM

RUN source ~/.nvm/nvm.sh &&
nvm install --lts

Set default Node.js version

RUN source ~/.nvm/nvm.sh &&
nvm use --lts

Verify Node.js and npm installation

RUN source ~/.nvm/nvm.sh &&
node -v && npm -v

Set default Node.js version

RUN source ~/.nvm/nvm.sh &&
nvm debug

What happened?

If I use current nvm (v0.40.1) it looks for a file - which is not present see these few lines of output

#9 0.421 Downloading and installing node v22.12.0...
#9 0.518 Downloading https://nodejs.org/dist/v22.12.0/node-v22.12.0-linux-x64-musl.tar.gz...
#=#=# curl: (22) The requested URL returned error: 404
#9 0.692
#9 0.695 download from https://nodejs.org/dist/v22.12.0/node-v22.12.0-linux-x64-musl.tar.gz failed

If I use older nvm (v0.39.3) it download and install the node but the node -v fails and node is not present. See the output

#10 [3/9] RUN curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.3/...
#10 0.174 % Total % Received % Xferd Average Speed Time Time Time Current
#10 0.174 Dload Upload Total Spent Left Speed
100 15916 100 15916 0 0 257k 0 --:--:-- --:--:-- --:--:-- 259k
#10 0.246 => Downloading nvm from git to '/root/.nvm'
=> Cloning into '/root/.nvm'...
#10 0.911 * (HEAD detached at FETCH_HEAD)
#10 0.911 master
#10 0.913 => Compressing and cleaning up git repository
#10 0.916
#10 0.921 => Profile not found. Tried ~/.bashrc, ~/.bash_profile, ~/.zprofile, ~/.zshrc, and ~/.profile.
#10 0.921 => Create one of them and run this script again
#10 0.921 OR
#10 0.921 => Append the following lines to the correct file yourself:
#10 0.921
#10 0.921 export NVM_DIR="$HOME/.nvm"
#10 0.921 [ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh" # This loads nvm
#10 0.921
#10 0.951 => Close and reopen your terminal to start using nvm or run the following to use it now:
#10 0.951
#10 0.951 export NVM_DIR="$HOME/.nvm"
#10 0.951 [ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh" # This loads nvm
#10 DONE 1.0s
#9 [4/9] RUN source ~/.nvm/nvm.sh && nvm install --lts
#9 0.205 Installing latest LTS version.
#9 0.398 expr: warning: '^lts/-[1-9][0-9]$': using '^' as the first character
#9 0.398 of a basic regular expression is not portable; it is ignored
#9 0.459 Downloading and installing node v22.12.0...
#9 0.703 Downloading https://nodejs.org/dist/v22.12.0/node-v22.12.0-linux-x64.tar.gz...
######################################################################## 100.0%
#9 1.922 Computing checksum with sha256sum
#9 2.186 Checksums matched!
#9 4.425 Now using node v22.12.0 (npm v)
#9 4.485 Creating default alias: default -> lts/
(-> v22.12.0 *)
#9 DONE 5.0s
#8 [5/9] RUN source ~/.nvm/nvm.sh && nvm use --lts
#8 0.410 Now using node v22.12.0 (npm v)
#8 DONE 0.5s
#7 [6/9] RUN source ~/.nvm/nvm.sh && node -v && npm -v
#7 0.348 /bin/sh: node: not found
#7 ERROR: process "/bin/sh -c source ~/.nvm/nvm.sh && node -v && npm -v" did not complete successfully: exit code: 127

[6/9] RUN source ~/.nvm/nvm.sh && node -v && npm -v:


process "/bin/sh -c source ~/.nvm/nvm.sh && node -v && npm -v" did not complete successfully: exit code: 127

A typical node install using apk add or using n package I end up getting older version 22.11.0 and I need to get 22.12.0

What did you expect to happen?

Is there anything in any of your profile files that modifies the PATH?

If you are having installation issues, or getting "N/A", what does curl -I --compressed -v https://nodejs.org/dist/ print out?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions