-
-
Notifications
You must be signed in to change notification settings - Fork 8.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
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
Comments
I added following command before the install an here is the output RUN source ~/.nvm/nvm.sh Output #8 [3/9] RUN curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.1/...
|
Please fill out the issue template; it’s there for a reason. You shouldn’t be modifying the PATH at all; nvm does that for you. As for busybox, i believe it’s so is not posix compliant - you may need to install a working one. See also https://github.com/nvm-sh/nvm?tab=readme-ov-file#installing-nvm-on-alpine-linux |
Thank you for the prompt response and I changed the script based on the link you provided... and the script looks like this and see the output below. (This has portion of nvm debug output) Please note that yesterday, in one of the test it downloaded the source and compiled it even after that I was seeing the older nodejs (22.11.0) not the current one (22.12.0). My goal is to get the 22.12.0 node js. I even tried the npm package n to get the latest and it also get one version older... is there something wrong at the nodejs provider... the default installation also get the one version older... Script: Install NVMRUN curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.1/install.sh | bash Set default Node.js versionRUN source ~/.nvm/nvm.sh RUN source ~/.nvm/nvm.sh RUN source ~/.nvm/nvm.sh Install the latest Node.js version using NVMRUN source ~/.nvm/nvm.sh && Set default Node.js versionRUN source ~/.nvm/nvm.sh && Verify Node.js and npm installationRUN source ~/.nvm/nvm.sh && Output: #6 [ 3/11] RUN curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40....
|
So, that the prefix is showing up as /usr/local is a problem - do you have the PREFIX env var set? Note that termux sets this, which means it’s incompatible with npm. Also, nvm debug is failing correctly; it’s not meant to ever return a zero exit code. |
Once again thank you for your kind attention and time... #5 0.300 $PREFIX: '' I do use a base image that is built by another group. An it is possible that they may be doing some with it. Is there something I could do to overwrite the value. If so, what value I should set... And in the next run should I remove nvm debug as this stops the script for me... |
It's fine to include nvm debug, but you don't want its return code to abort the process - so maybe Why does it think that |
After I added these in the script it downloaded the source and try to compile but never finished,.. RUN source ~/.nvm/nvm.sh |
Compiling node does take a long time. tbh i'd suggest not using alpine at all; its small size means you have to spend lots of time and disk space doing all the things it's missing. |
It seems the nvm would not work for me... would you recommend any other alternate. The default nodejs installation and using npm package n and even apk add all are end up getting one version older which is strange... why would it not get the lts? |
I can't help with alternatives to nvm, unfortunately. Is there a reason you are required to use alpine/busybox as your base image? |
No worries. Our company policy is to use the (Golden) image they provide as base. It seems nvm is not going to work in this scenario and you can close the ticket. I'm still curious why the standard install get me a version older and I can't find the answer for it. Since the standard install did not worked that is why I looked into using the nvm. |
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
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?The text was updated successfully, but these errors were encountered: