Friday, 22 November 2019

install nodejs into docker image




install nvm first:
https://github.com/nvm-sh/nvm#install-script
wget -qO- https://raw.githubusercontent.com/nvm-sh/nvm/v0.35.1/install.sh | bash


then:
export NVM_DIR="$([ -z "${XDG_CONFIG_HOME-}" ] && printf %s "${HOME}/.nvm" || printf %s "${XDG_CONFIG_HOME}/nvm")"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm




above doesn't work for me


below one works:

apk add  --no-cache --repository http://dl-cdn.alpinelinux.org/alpine/v3.7/main/ nodejs=8.9.3-r1




all in one:

```
ARCH='x64'
NODE_VERSION=10.17.0
apk add --no-cache libstdc++
apk add --no-cache --virtual .build-deps curl
curl -fsSLO --compressed "https://unofficial-builds.nodejs.org/download/release/v$NODE_VERSION/node-v$NODE_VERSION-linux-$ARCH-musl.tar.xz"
tar -xJf "node-v$NODE_VERSION-linux-$ARCH-musl.tar.xz" -C /usr/local --strip-components=1 --no-same-owner
ln -s /usr/local/bin/node /usr/local/bin/nodejs;
```
if you don't have apk, then, you can try apt:
you may also need to check your architecture by different commands:
```
dpkg --print-architecture
or
apk --print-arch
```
for more info, you can check : https://github.com/nodejs/docker-node/tree/master/13
```
ARCH='x64'
NODE_VERSION=13.3.0
apt-get update
apt-get install curl
curl -fsSLO --compressed "https://nodejs.org/dist/v$NODE_VERSION/node-v$NODE_VERSION-linux-$ARCH.tar.xz"
tar -xJf "node-v$NODE_VERSION-linux-$ARCH.tar.xz" -C /usr/local --strip-components=1 --no-same-owner
```

No comments:

Post a comment