diff --git a/Vagrantfile b/Vagrantfile index 974f9d18..eb70f1d4 100644 --- a/Vagrantfile +++ b/Vagrantfile @@ -195,6 +195,9 @@ Vagrant.configure("2") do |config| # Install Nodejs # config.vm.provision "shell", path: "https://raw.github.com/#{github_username}/#{github_repo}/#{github_branch}/scripts/nodejs.sh", privileged: false, args: nodejs_packages.unshift(nodejs_version) + # Install Nodejs Basic + # config.vm.provision "shell", path: "https://raw.github.com/#{github_username}/#{github_repo}/#{github_branch}/scripts/nodebasic.sh", privileged: false, args: nodejs_packages` + # Install Ruby Version Manager (RVM) # config.vm.provision "shell", path: "https://raw.github.com/#{github_username}/#{github_repo}/#{github_branch}/scripts/rvm.sh", privileged: false, args: ruby_gems.unshift(ruby_version) diff --git a/scripts/nodebasic.sh b/scripts/nodebasic.sh new file mode 100644 index 00000000..8d0f1822 --- /dev/null +++ b/scripts/nodebasic.sh @@ -0,0 +1,34 @@ +#!/usr/bin/env bash + +echo ">>> Adding PPA's and Installing Node.js" + +# Add repo for latest Node.js +sudo add-apt-repository -y ppa:chris-lea/node.js + +# Update +sudo apt-get update + +# Install node.js +sudo apt-get install -y nodejs + +# Change where npm global packages location +npm config set prefix ~/npm + +# Add new npm global packages location to PATH +printf "\n# Add new npm global packages location to PATH\n%s" 'export PATH=$PATH:~/npm/bin' >> ~/.bash_profile + +# Add new npm root to NODE_PATH +printf "\n# Add the new npm root to NODE_PATH\n%s" 'export NODE_PATH=$NODE_PATH:~/npm/lib/node_modules' >> ~/.bash_profile + +# Test if Node.js is installed +node -v > /dev/null 2>&1 +NODE_IS_INSTALLED=$? + +if [ $NODE_IS_INSTALLED -eq 0 ]; then + echo ">>> Installing Global Node Modules" + echo ">>> Installing " $@ + npm install -g $@ +else + echo "!!! Installing Global Node Modules failed." + echo "!!! Please make sure you have installed Node.js." +fi