-
Notifications
You must be signed in to change notification settings - Fork 20
Expand file tree
/
Copy path02-nodenv
More file actions
executable file
·38 lines (29 loc) · 1.17 KB
/
Copy path02-nodenv
File metadata and controls
executable file
·38 lines (29 loc) · 1.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#! /bin/sh
set -e
set -x
export DEBIAN_FRONTEND=noninteractive
nodenv_root=/opt/nodenv
## get latest nodejs version (26.x.x) from https://nodejs.org/download/release/index.json
node_version=$(/bin/bash /tmp/build/rails7/helpers/latest-nodejs-version v26.)
## install nodenv into /opt/nodenv
git clone https://github.com/nodenv/nodenv.git ${nodenv_root}
## install nodenv plugins
git clone https://github.com/nodenv/node-build.git ${nodenv_root}/plugins/node-build
git clone https://github.com/nodenv/nodenv-update.git ${nodenv_root}/plugins/nodenv-update
git clone https://github.com/nodenv/nodenv-aliases.git ${nodenv_root}/plugins/nodenv-aliases
## install /etc/profile.d/nodenv.sh
cat <<PROFILE > /etc/profile.d/nodenv.sh
export NODENV_ROOT=${nodenv_root}
export PATH=\${NODENV_ROOT}/bin:\${PATH}
eval "\$(nodenv init -)"
PROFILE
if etckeeper unclean 1>/dev/null 2>/dev/null; then
sudo etckeeper commit "add /etc/profile.d/nodenv.sh to use ${nodenv_root}"
fi
### create shims,versions
set +e
bash -l -c "nodenv rehash"
set -e
## install nodejs
bash -l -c "nodenv install ${node_version}"
bash -l -c "nodenv global ${node_version}"