From d0eb13b5ec8d8fd9a1e42d0506c63119bc5de53a Mon Sep 17 00:00:00 2001
From: Bob Mottram <bob@freedombone.net>
Date: Fri, 15 Sep 2017 19:50:23 +0100
Subject: [PATCH] Installing npm on mesh image

---
 src/freedombone-utils-nodejs | 22 ++++++++++------------
 1 file changed, 10 insertions(+), 12 deletions(-)

diff --git a/src/freedombone-utils-nodejs b/src/freedombone-utils-nodejs
index ed109acfc..c40cbd057 100755
--- a/src/freedombone-utils-nodejs
+++ b/src/freedombone-utils-nodejs
@@ -74,28 +74,26 @@ function mesh_install_nodejs {
         exit 7235728
     fi
 
-    if [ -f /usr/share/npm/bin/npm-cli.js ]; then
-        ln -s /usr/share/npm/bin/npm-cli.js /usr/bin/npm
-    else
-        wget https://www.npmjs.com/install.sh -O $rootdir/root/npm_install.sh
-        if [ ! -f $rootdir/root/npm_install.sh ]; then
-            echo $'Unable to download npm installer'
-            exit 8793636
-        fi
-        chroot "$rootdir" chmod +x /root/npm_install.sh
-        sed -i "s|t=\"\${npm_install}\"|t=\"$NPM_VERSION\"|g" $rootdir/root/npm_install.sh
-        chroot "$rootdir" /root/npm_install.sh
+    wget https://www.npmjs.com/install.sh -O $rootdir/root/npm_install.sh
+    if [ ! -f $rootdir/root/npm_install.sh ]; then
+        echo $'Unable to download npm installer'
+        exit 8793636
     fi
+    chroot "$rootdir" chmod +x /root/npm_install.sh
+    sed -i "s|t=\"\${npm_install}\"|t=\"$NPM_VERSION\"|g" $rootdir/root/npm_install.sh
+    chroot "$rootdir" /root/npm_install.sh
+
     if [ ! -f $rootdir/usr/bin/npm ]; then
         echo $'npm was not installed'
         exit 5290462
     fi
+    cp $rootdir/usr/bin/npm $rootdir/root/npm
 
     # update from the old debian nodejs version
     get_npm_arch
     chroot "$rootdir" npm install --arch=$NPM_ARCH -g n@${NODEJS_N_VERSION} --save
     chroot "$rootdir" n --arch $N_ARCH ${NODEJS_VERSION}
-    chroot "$rootdir" npm install -g --arch $NPM_ARCH npm@${NPM_VERSION} --save
+    cp $rootdir/root/npm $rootdir/usr/bin/npm
 }
 
 function remove_nodejs {
-- 
GitLab