29
29
# Allows overriding the branch or commit to build in chia-blockchain-gui
30
30
SUBMODULE_BRANCH=$1
31
31
32
- nodejs_is_installed () {
33
- if ! npm version > /dev/null 2>&1 ; then
34
- return 1
32
+ do_check_npm_install () {
33
+ if ! command -v npm > /dev/null 2>&1 ; then
34
+ echo " npm is not installed. Please install NodeJS>=20 and npm>=10 manually"
35
+ exit 1
36
+ fi
37
+
38
+ if ! command -v node > /dev/null 2>&1 ; then
39
+ echo " NodeJS is not installed. Please install NodeJS>=20 and npm>=10 manually"
40
+ exit 1
35
41
fi
36
- return 0
37
- }
38
42
39
- do_install_npm_locally () {
40
43
NODEJS_VERSION=" $( node -v | cut -d' .' -f 1 | sed -e ' s/^v//' ) "
41
44
NPM_VERSION=" $( npm -v | cut -d' .' -f 1) "
42
45
@@ -48,42 +51,8 @@ do_install_npm_locally() {
48
51
echo " Current npm version($( npm -v) ) is less than 10. GUI app requires npm>=10."
49
52
fi
50
53
51
- if [ " $( uname) " = " OpenBSD" ] || [ " $( uname) " = " FreeBSD" ]; then
52
- # `n` package does not support OpenBSD/FreeBSD
53
- echo " Please install NodeJS>=20 and/or npm>=10 manually"
54
- exit 1
55
- fi
56
-
57
- NPM_GLOBAL=" ${SCRIPT_DIR} /build_scripts/npm_global"
58
- # install-gui.sh can be executed
59
- echo " cd ${NPM_GLOBAL} "
60
- cd " ${NPM_GLOBAL} "
61
- if [ " $NPM_VERSION " -lt " 6" ]; then
62
- # Ubuntu image of Amazon ec2 instance surprisingly uses [email protected]
63
- # which doesn't support `npm ci` as of 27th Jan, 2022
64
- echo " npm install"
65
- npm install
66
- else
67
- echo " npm ci"
68
- npm ci
69
- fi
70
- export N_PREFIX=${SCRIPT_DIR} /.n
71
- PATH=" ${N_PREFIX} /bin:$( npm prefix) /node_modules/.bin:${PATH} "
72
- export PATH
73
- # `n 20` here installs nodejs@20 under $N_PREFIX directory
74
- echo " n 20"
75
- n 20
76
- echo " Current NodeJS version: $( node -v) "
77
- echo " Current npm version: $( npm -v) "
78
- if [ " $( node -v | cut -d' .' -f 1 | sed -e ' s/^v//' ) " -lt " 20" ]; then
79
- echo " Error: Failed to install NodeJS>=20"
80
- exit 1
81
- fi
82
- if [ " $( npm -v | cut -d' .' -f 1) " -lt " 10" ]; then
83
- echo " Error: Failed to install npm>=10"
84
- exit 1
85
- fi
86
- cd " ${SCRIPT_DIR} "
54
+ echo " Please install NodeJS>=20 and/or npm>=10 manually"
55
+ exit 1
87
56
else
88
57
echo " Found NodeJS $( node -v) "
89
58
echo " Found npm $( npm -v) "
@@ -106,79 +75,7 @@ patch_inconsistent_npm_issue() {
106
75
ln -s " $( command -v npm) " " ${node_module_dir} /.bin/npm"
107
76
}
108
77
109
- # Manage npm and other install requirements on an OS specific basis
110
- if [ " $( uname) " = " Linux" ]; then
111
- # LINUX=1
112
- if type apt-get > /dev/null 2>&1 ; then
113
- # Debian/Ubuntu
114
-
115
- # Check if we are running a Raspberry PI 4
116
- if [ " $( uname -m) " = " aarch64" ] &&
117
- [ " $( uname -n) " = " raspberrypi" ]; then
118
- # Check if NodeJS & NPM is installed
119
- type npm > /dev/null 2>&1 || {
120
- echo >&2 " Please install NODEJS&NPM manually"
121
- }
122
- else
123
- if ! nodejs_is_installed; then
124
- echo " nodejs is not installed. Installing..."
125
- echo " sudo apt-get install -y npm nodejs libxss1"
126
- sudo apt-get install -y npm nodejs libxss1
127
- fi
128
- do_install_npm_locally
129
- fi
130
- elif type yum > /dev/null 2>&1 && [ ! -f " /etc/redhat-release" ] && [ ! -f " /etc/centos-release" ] && [ ! -f /etc/rocky-release ] && [ ! -f /etc/fedora-release ]; then
131
- # AMZN 2
132
- if ! nodejs_is_installed; then
133
- echo " Installing nodejs on Amazon Linux 2."
134
- curl -sL https://rpm.nodesource.com/setup_20.x | sudo bash -
135
- sudo yum install -y nodejs
136
- fi
137
- do_install_npm_locally
138
- elif type yum > /dev/null 2>&1 && [ ! -f /etc/rocky-release ] && [ ! -f /etc/fedora-release ] && [ -f /etc/redhat-release ] || [ -f /etc/centos-release ]; then
139
- # CentOS or Redhat
140
- if ! nodejs_is_installed; then
141
- echo " Installing nodejs on CentOS/Redhat."
142
- curl -sL https://rpm.nodesource.com/setup_20.x | sudo bash -
143
- sudo yum install -y nodejs
144
- fi
145
- do_install_npm_locally
146
- elif type yum > /dev/null 2>&1 && [ -f /etc/rocky-release ] || [ -f /etc/fedora-release ]; then
147
- # RockyLinux
148
- if ! nodejs_is_installed; then
149
- echo " Installing nodejs on RockyLinux/Fedora"
150
- sudo dnf module enable nodejs:20
151
- sudo dnf install -y nodejs
152
- fi
153
- do_install_npm_locally
154
- elif type pacman > /dev/null 2>&1 && [ -f /etc/arch-release ]; then
155
- # Arch Linux
156
- if ! nodejs_is_installed; then
157
- echo " Installing nodejs on Arch Linux"
158
- sudo pacman -S nodejs npm
159
- fi
160
- do_install_npm_locally
161
- fi
162
- elif [ " $( uname) " = " Darwin" ] && type brew > /dev/null 2>&1 ; then
163
- # MacOS
164
- if ! nodejs_is_installed; then
165
- echo " Installing nodejs on MacOS"
166
- brew install npm
167
- fi
168
- do_install_npm_locally
169
- elif [ " $( uname) " = " OpenBSD" ]; then
170
- if ! nodejs_is_installed; then
171
- echo " Installing nodejs"
172
- pkg_add node
173
- fi
174
- do_install_npm_locally
175
- elif [ " $( uname) " = " FreeBSD" ]; then
176
- if ! nodejs_is_installed; then
177
- echo " Installing nodejs"
178
- pkg install node
179
- fi
180
- do_install_npm_locally
181
- fi
78
+ do_check_npm_install
182
79
183
80
echo " "
184
81
0 commit comments