Last active
October 7, 2016 11:30
-
-
Save abbotto/a86a54b3f087fb57911c0c80f3e32a61 to your computer and use it in GitHub Desktop.
NodeJS Environment Setup Tasks
This file contains hidden or 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/bash | |
printf "\n-----------------------------------------\n" | |
printf "N.E.S.T.\n" | |
printf "NodeJS Environment Setup Tasks" | |
printf "\n-----------------------------------------\n" | |
# Requires nvm and nodejs | |
# Put this in the same folder as "package.json" | |
# Source the following script to make nvm() available | |
. ~/.nvm/nvm.sh | |
printf "\nGetting the correct NodeJS version for the current project...\n" | |
NODE_VERSION=$(node -p -e "require('./package.json').engines.node") | |
printf "v$NODE_VERSION is required." | |
printf "\n\nSwitching to v$NODE_VERSION...\n" | |
rm -rf node_modules | |
nvm install $NODE_VERSION | |
printf "\nInstalling v$NODE_VERSION modules...\n" | |
npm install | |
printf "\nNodeJS has been setup for your project.\n" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment