Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Node.js installation fail. /usr/bin/env: ‘node’: No such file or directory #801

Closed
Botspot opened this issue Jul 10, 2021 · 3 comments
Closed

Comments

@Botspot
Copy link
Owner

Botspot commented Jul 10, 2021

I'm not exactly sure what is going on here, but it's been happening for a while.

Installing Node.js with install script
=> Downloading nvm from git to '/home/pi/.config/nvm'
=> Cloning into '/home/pi/.config/nvm'...
* (HEAD detached at FETCH_HEAD)
  master
=> Compressing and cleaning up git repository

=> nvm source string already in /home/pi/.bashrc
=> bash_completion source string already in /home/pi/.bashrc
/usr/bin/env: ‘node’: No such file or directory
=> Close and reopen your terminal to start using nvm or run the following to use it now:

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
/home/pi/pi-apps/apps/Node.js/install: line 15: nvm: command not found
failed to install node.js! trying again with different NVM_DIR...
/home/pi/pi-apps/apps/Node.js/install: line 15: nvm: command not found
Failed to install Node.js using nvm!

Failed to install Node.js with install script!
@Botspot
Copy link
Owner Author

Botspot commented Jul 10, 2021

Turns out the install script was seriously messed up. I've changed it to this:

#!/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:
export NVM_DIR="$HOME/.nvm"
mkdir -p "$NVM_DIR"
wget -qO- https://raw.githubusercontent.com/nvm-sh/nvm/v0.38.0/install.sh | bash || error "Failed to install nvm!"

source "$NVM_DIR/nvm.sh" || error "Failed to source $NVM_DIR/nvm.sh"
source "$NVM_DIR/bash_completion" || error "Failed to source $NVM_DIR/bash_completio"

#Install NodeJS, if nvm fails, try again with a different 'NVM_DIR"
if ! nvm install --lts ;then
  echo "failed to install node.js! trying again with different NVM_DIR..."
  NVM_DIR="$HOME/.config/nvm" nvm install --lts || error "Failed to install Node.js using nvm!"
fi

It worked now.

@Botspot Botspot closed this as completed Jul 10, 2021
@Botspot
Copy link
Owner Author

Botspot commented Jul 10, 2021

I just noticed that nvm is downloading node arm64!! My system is armhf but using the 64-bit kernel. Time to see what happened to my PR on the nvm repo...

@Botspot Botspot reopened this Jul 10, 2021
@Botspot
Copy link
Owner Author

Botspot commented Jul 11, 2021

Fixed more than 8 various bugs in the scripts with commit e9de2f1.

We should be good to go from now on.

@Botspot Botspot closed this as completed Jul 11, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant