I was wondering what is the purpose of piping the downloaded file by
sudo -E bash - in the following shell:
curl -sL https://deb.nodesource.com/setup_5.x | sudo -E bash -
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It only takes a minute to sign up.Sign up to join this community
It's a short way of executing a script without having to save the file and then execute it. When you save the file and then execute it, a number of things can go wrong:
sh foo.shinstead of
./foo.sh), and forgot to set execute permissions
By providing a single command line to execute, the developers can decrease the number of places where things can go wrong due to luser error.
Personally, I despise piping curl to bash. It's not safe.
Agreed with @muru you should not execute some random bash script from the internet.
Unzip the binary archive to any directory you wanna install Node, I use
sudo mkdir -p /usr/local/lib/nodejs # instead of XX use the version number you downloaded sudo tar -xJvf node-XX-XX.tar.xz -C /usr/local/lib/nodejs
~/.profile, add below to the end
# Nodejs VERSION=vXX.XX.0 # <--- Put the version you downloaded DISTRO=linux-x64 export PATH=/usr/local/lib/nodejs/node-$VERSION-$DISTRO/bin:$PATH
Check if it works
node -v npm version