浏览代码

Fixing npm hell

Bob Mottram 7 年前
父节点
当前提交
2b9c6c3fa3
共有 1 个文件被更改,包括 8 次插入41 次删除
  1. 8
    41
      src/freedombone-utils-nodejs

+ 8
- 41
src/freedombone-utils-nodejs 查看文件

13
 # License
13
 # License
14
 # =======
14
 # =======
15
 #
15
 #
16
-# Copyright (C) 2014-2016 Bob Mottram <bob@freedombone.net>
16
+# Copyright (C) 2014-2017 Bob Mottram <bob@freedombone.net>
17
 #
17
 #
18
 # This program is free software: you can redistribute it and/or modify
18
 # This program is free software: you can redistribute it and/or modify
19
 # it under the terms of the GNU Affero General Public License as published by
19
 # it under the terms of the GNU Affero General Public License as published by
57
 
57
 
58
     cat <<EOF > ${rootdir}/root/install-nodejs.sh
58
     cat <<EOF > ${rootdir}/root/install-nodejs.sh
59
 #!/bin/bash
59
 #!/bin/bash
60
-PATH="/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:/bin"
61
-NODE_PATH="/usr/lib/node_modules"
62
-cp /usr/bin/nodejs /usr/local/bin/node
63
-cp /usr/bin/nodejs /usr/bin/node
64
-#/usr/bin/curl -0 -L https://npmjs.org/install.sh | sh
60
+npm install -g npm@${NPM_VERSION} --save
65
 npm install -g n@${NODEJS_N_VERSION} --save
61
 npm install -g n@${NODEJS_N_VERSION} --save
66
-n ${NODEJS_VERSION}
67
-exit 0
62
+npm install -g pug@2.0.0-beta6 --save
63
+npm install -g graceful-fs@4.1.10 --save
64
+npm install -g minimatch@3.0.3 --save
65
+cp /usr/bin/nodejs /usr/local/bin/node
68
 EOF
66
 EOF
69
     chroot "${rootdir}" chmod +x /root/install-nodejs.sh
67
     chroot "${rootdir}" chmod +x /root/install-nodejs.sh
70
     chroot "${rootdir}" /root/install-nodejs.sh
68
     chroot "${rootdir}" /root/install-nodejs.sh
173
         exit 63962
171
         exit 63962
174
     fi
172
     fi
175
 
173
 
176
-    cp /usr/bin/nodejs /usr/local/bin/node
177
-    cp /usr/bin/nodejs /usr/bin/node
178
-
179
-    npm install -g n@${NODEJS_N_VERSION} --save
180
-    if [ ! -f /usr/local/bin/n ]; then
181
-        exit 325723
182
-    fi
183
-    cp /usr/local/bin/n /usr/bin/n
184
-    n ${NODEJS_VERSION}
185
-    if [ ! -f /usr/local/bin/node ]; then
186
-        exit 347835
187
-    fi
188
-    cp /usr/local/bin/node /usr/bin/nodejs
189
-    cp /usr/local/bin/node /usr/bin/node
190
-    if [ -f /usr/local/lib/node_modules/npm ]; then
191
-        rm -rf /usr/local/lib/node_modules/npm
192
-    fi
193
-    if [ -d /usr/local/lib/node_modules/npm ]; then
194
-        rm -rf /usr/local/lib/node_modules/npm
195
-    fi
196
     npm install -g npm@${NPM_VERSION} --save
174
     npm install -g npm@${NPM_VERSION} --save
197
-    if [ ! -f /usr/local/bin/npm ]; then
198
-        if [ ! -f /usr/bin/npm ]; then
199
-            exit 3
200
-        fi
201
-    fi
202
-    if [ -f /usr/local/bin/npm ]; then
203
-        cp /usr/local/bin/npm /usr/bin/npm
204
-    fi
175
+    npm install -g n@${NODEJS_N_VERSION} --save
205
     npm install -g pug@2.0.0-beta6 --save
176
     npm install -g pug@2.0.0-beta6 --save
206
     npm install -g graceful-fs@4.1.10 --save
177
     npm install -g graceful-fs@4.1.10 --save
207
     npm install -g minimatch@3.0.3 --save
178
     npm install -g minimatch@3.0.3 --save
208
 
179
 
209
-    # second npm install attempt seems necessary
210
-    npm install -g npm@${NPM_VERSION} --save
211
-    if [ -f /usr/local/bin/npm ]; then
212
-        cp /usr/local/bin/npm /usr/bin/npm
213
-    fi
180
+    cp /usr/bin/nodejs /usr/local/bin/node
214
 
181
 
215
     # node seems tricky so here we're going to double check
182
     # node seems tricky so here we're going to double check
216
     # that the versions we expect did get installed
183
     # that the versions we expect did get installed