gitlab-build-images/scripts/install-node
Takuya Noguchi adc2958921 Upgrade the default Node.js version from 12.4.0 to 14.16.0
Also node-14 will be changed from 14.15.4 to 14.16.0 as intended,
while node-12 will not be changed staying with 12.4.0.

Signed-off-by: Takuya Noguchi <takninnovationresearch@gmail.com>
2021-02-27 13:25:53 +00:00

27 lines
855 B
Bash
Executable file

#!/bin/bash
set -xeuo pipefail
IFS=$'\n\t'
NODE_INSTALL_VERSION=${1:-14.16.0}
YARN_INSTALL_VERSION=${2:-1.21.1-1}
# Map MAJOR.MINOR.patch -> MAJOR.x
NODE_MAJOR=`echo $NODE_INSTALL_VERSION | sed -r -e "s/([0-9]+)\.[0-9]+.*/\1\.x/g"`
# add official debian repos for node and yarn
curl -sS -L https://deb.nodesource.com/setup_${NODE_MAJOR} | bash -
curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add -
echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list
apt-get update
NODE_FILE_NAME="nodejs_$NODE_INSTALL_VERSION-1nodesource1_amd64.deb"
curl -s -O "https://deb.nodesource.com/node_$NODE_MAJOR/pool/main/n/nodejs/$NODE_FILE_NAME"
dpkg -i "$NODE_FILE_NAME"
rm -f "$NODE_FILE_NAME"
apt-get install -y yarn=$YARN_INSTALL_VERSION
apt-get autoremove -yq
apt-get clean -yqq
rm -rf /var/lib/apt/lists/*