From f13551a8c30544da3793d37a0df35b142c1333db Mon Sep 17 00:00:00 2001 From: Botspot Date: Tue, 23 Mar 2021 11:17:11 -0500 Subject: [PATCH] node.js fix for 64bit kernel/32bit userland situations --- apps/Node.js/install-32 | 33 ++++++++++++++++++++++++++++ apps/Node.js/{install => install-64} | 1 + apps/Node.js/uninstall | 2 ++ 3 files changed, 36 insertions(+) create mode 100755 apps/Node.js/install-32 rename apps/Node.js/{install => install-64} (97%) diff --git a/apps/Node.js/install-32 b/apps/Node.js/install-32 new file mode 100755 index 0000000..8e8d4ed --- /dev/null +++ b/apps/Node.js/install-32 @@ -0,0 +1,33 @@ +#!/bin/bash + +DIRECTORY="$(dirname "$(dirname "$( cd "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P )")")" + +function error { + echo -e "\\e[91m$1\\e[39m" + exit 1 +} + +#Checking if using armv6 +if [ ! -z "$(cat /proc/cpuinfo | grep ARMv6)" ];then + error "armv6 cpu not supported" +fi + +if ! command -v curl >/dev/null ; then + echo -e "\033[0;31mcurl: command not found.\e[39m +You need to install curl first. If you are on a debian system, this command should install it: +\e[4msudo apt install curl\e[0m" + exit 1 +fi + +#Install nvm manager: +curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.37.2/install.sh | bash || error "Failed to install nvm!" +export NVM_DIR="$HOME/.config/nvm" +[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm +[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion + +#patch nvm script to forcibly use armhf +sed -i 's/^ nvm_echo "${NVM_ARCH}"/ NVM_ARCH=armv7l ; nvm_echo "${NVM_ARCH}"/g' "$NVM_DIR/nvm.sh" + +#Install NodeJS: +nvm install --lts +#sudo npm i -g nodejs \ No newline at end of file diff --git a/apps/Node.js/install b/apps/Node.js/install-64 similarity index 97% rename from apps/Node.js/install rename to apps/Node.js/install-64 index e0fc18b..5636146 100755 --- a/apps/Node.js/install +++ b/apps/Node.js/install-64 @@ -27,3 +27,4 @@ export NVM_DIR="$HOME/.config/nvm" #Install NodeJS: nvm install --lts +#sudo npm i -g nodejs \ No newline at end of file diff --git a/apps/Node.js/uninstall b/apps/Node.js/uninstall index e2da3f9..149f162 100755 --- a/apps/Node.js/uninstall +++ b/apps/Node.js/uninstall @@ -9,6 +9,8 @@ function error { #Uninstall NodeJS export NVM_DIR="$HOME/.config/nvm" +[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm +[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion cd $NVM_DIR nvm uninstall default || error "Failed to purge Node.JS!"