Last active
August 13, 2018 21:21
-
-
Save citricacid-pl/1188926d1b6ab141d5f8 to your computer and use it in GitHub Desktop.
Installs node.js on Ubuntu
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# Just some settings | |
bold=`tput bold` | |
green=`tput setaf 2` | |
normal=`tput sgr0` | |
# Install prerequisites | |
echo "${bold}Install prerequisites${normal}" | |
sudo apt-get install -y build-essential curl | |
# Help taken from https://github.com/sindresorhus/guides/blob/master/npm-global-without-sudo.md | |
echo "${bold}Install node.js${normal}" | |
curl -sL https://deb.nodesource.com/setup_8.x | sudo -E bash - | |
sudo apt-get install -y nodejs | |
mkdir "${HOME}/.npm-packages" | |
touch ~/.npmrc | |
if grep -q "prefix" ~/.npmrc | |
then | |
echo '' | |
else | |
echo 'prefix=${HOME}/.npm-packages' >> ~/.npmrc | |
fi | |
if grep -q "NPM_PACKAGES" ~/.bashrc | |
then | |
echo '' | |
else | |
echo 'NPM_PACKAGES="${HOME}/.npm-packages"' >> ~/.bashrc | |
echo 'PATH="$NPM_PACKAGES/bin:$PATH"' >> ~/.bashrc | |
echo 'unset MANPATH' >> ~/.bashrc | |
echo 'export MANPATH="$NPM_PACKAGES/share/man:$(manpath)"' >> ~/.bashrc | |
. $HOME/.bashrc | |
fi | |
# A fix for WebStorm to have grunt tab working | |
sudo ln -s `which node` /usr/local/bin/node | |
# Install Yarn | |
curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add - | |
echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list | |
sudo apt-get update && sudo apt-get install yarn -y | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Download the script. Open terminal and cd to the dir it is downloaded into. Give the script execution rights:
Then run with: