photoprism/scripts/dist/install-nodejs.sh

35 lines
1.1 KiB
Bash
Raw Normal View History

#!/usr/bin/env bash
2022-02-17 13:54:42 +01:00
# This installs NodeJS, NPM and TestCafe on Linux.
# bash <(curl -s https://raw.githubusercontent.com/photoprism/photoprism/develop/scripts/dist/install-nodejs.sh)
PATH="/usr/local/sbin:/usr/sbin:/sbin:/usr/local/bin:/usr/bin:/bin:/scripts:$PATH"
# Abort if not executed as root.
2022-02-17 13:54:42 +01:00
if [[ $(id -u) != "0" ]]; then
echo "Usage: run ${0##*/} as root" 1>&2
2022-02-17 13:54:42 +01:00
exit 1
fi
set -e
. /etc/os-release
# NodeJS version.
NODE_MAJOR=20
# Create /etc/apt/keyrings/nodesource.gpg
mkdir -p /etc/apt/keyrings
curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg
# Create /etc/apt/sources.list.d/nodesource.list
echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_$NODE_MAJOR.x nodistro main" | tee /etc/apt/sources.list.d/nodesource.list
echo "Installing NodeJS and NPM from deb.nodesource.com..."
apt-get update && apt-get -qq install nodejs
echo "Installing TestCafe..."
2022-02-17 13:54:42 +01:00
npm config set cache ~/.cache/npm
npm install --unsafe-perm=true --allow-root -g npm@latest testcafe@3.2.0
echo "Done."