Files
photoprism/scripts/dist/install-nodejs.sh
2025-01-03 07:33:05 +01:00

36 lines
1.2 KiB
Bash
Executable File

#!/usr/bin/env bash
# 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.
if [[ $(id -u) != "0" ]]; then
echo "Usage: run ${0##*/} as root" 1>&2
exit 1
fi
set -e
. /etc/os-release
# NodeJS version to be installed.
NODE_MAJOR=22
# Download the signature key to "/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
# Add node repository source to "/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
# Upgrade NPM and install development dependencies.
echo "Installing TestCafe..."
npm config set cache ~/.cache/npm
npm install --unsafe-perm=true --allow-root -g npm@latest npm-check-updates@latest license-report@latest n@latest testcafe@3.6.2
echo "Done."