Last active
July 13, 2022 14:24
-
-
Save simbo/24f50efbb1f941b65e07 to your computer and use it in GitHub Desktop.
setup node.js with nvm within vagrant
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
# add this to your provision.sh | |
# [!] run as 'vagrant' | |
# install latest nvm | |
git clone https://github.com/creationix/nvm.git ~/.nvm && cd ~/.nvm && git checkout `git describe --abbrev=0 --tags` | |
source ~/.nvm/nvm.sh | |
echo "~/.nvm/nvm.sh" >> ~/.bashrc | |
# install latest stable node.js | |
echo "Installing node.js..." | |
nvm install stable &> /dev/null | |
nvm alias default stable | |
# install global node packages | |
echo "Installing global node.js packages... (please be patient)" | |
npm install -g gulp bower npm-check-updates | |
# install project dependencies and build | |
cd /vagrant/ | |
echo "Installing local node.js packages... (please be patient)" | |
npm install | |
bower install | |
npm run build-dev |
privileged: false
It can be simpler without having to create another script!
config.vm.provision "shell", privileged: false, inline: <<-SHELL
# Install NVM
git clone https://github.com/creationix/nvm.git ~/.nvm && cd ~/.nvm && git checkout `git describe --abbrev=0 --tags`
source ~/.nvm/nvm.sh
echo "source ~/.nvm/nvm.sh" >> ~/.bashrc
# Install Node
echo "Installing Node.js (please be patient)"
nvm install stable &> /dev/null
nvm alias default stable
# install global node packages
echo "Installing global node.js packages... (please be patient)"
# change 'gulp' to 'grunt' depending on project setup
npm install -g gulp bower npm-check-updates
# install project dependencies and build
cd /vagrant/
echo "Installing local node.js packages... (please be patient)"
npm install
bower install
# see package.json for respective build task
npm run build-dev
SHELL
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
What do you mean by : ?
I usually would put this script in Vagrantfile as:
How can I tell from
Vagrantfile
to execute as vagrant ?