server-debian/_installs/nodejs.sh

42 lines
599 B
Bash
Raw Normal View History

2023-07-18 16:20:48 +02:00
#!/usr/bin/zsh
# optional: remove old installs
2023-10-20 13:40:58 +02:00
apt purge -y \
2023-07-18 16:20:48 +02:00
nodejs npm
2023-10-20 13:40:58 +02:00
apt autoremove -y
2023-07-18 16:20:48 +02:00
2023-10-20 13:40:58 +02:00
rm /usr/bin/node
rm /usr/bin/npm
rm -rf /usr/share/npm
rm -rf /usr/share/nodejs
2023-07-18 16:20:48 +02:00
2023-10-20 13:40:58 +02:00
VER='18.18.0'
2023-07-18 16:20:48 +02:00
2023-10-20 13:40:58 +02:00
mv node-v$VER-linux-x64/bin/* \
/usr/local/bin/
mv node-v$VER-linux-x64/lib/node_modules/ \
/usr/local/lib/
2023-07-18 16:20:48 +02:00
2023-10-20 13:40:58 +02:00
mkdir -p \
2023-07-18 16:20:48 +02:00
'/usr/lib/nodejs' \
'/usr/lib/node_modules'
# fix permissions
2023-10-20 13:40:58 +02:00
chown -R $USER:$USER \
2023-07-18 16:20:48 +02:00
'/usr/local' \
'/usr/share' \
'/usr/lib/nodejs' \
'/usr/lib/node_modules'
# install version manager
npm i -g n
# bump node to latest LTS version
n lts
# update npm
npm i -g npm