Install NVM / NodeJs / EmberJS inside the firewall

I'm fine with that.

The original problem is that after installing NVM, you need to restart the terminal so that I can reinitialize the .bashrc parameters and then install NodeJS - so I thought that I would create a base unit with NVM already installed. Thus, the terminal will already be initialized with NVM material.

Not so ... Obviously, packaging the base box using Vagrant ignores everything in the / home / vagrant folder. ARRRRRRRGGGGHHHHH !!

In fact?!! 1-on

Is anyone lucky with this? How to install NVM inside a stray box? or even NodeJs without sudo? This is a terrible hole for rabbits, and I want to!

+5
source share
1 answer

I suggest you return to the shell provisioning strategy, I also skipped this hell, but it is definitely doable. After many searches, I found that for this you need two very vague documents:

The first and most important part is that you need to enable the creation of symbolic links in the VirtualBox instance with this line in your config.vm.provider block, without this, NVM just won’t work (see here ):

 config.vm.provider "virtualbox" do |vb| # (...) vb.customize ["setextradata", :id, "VBoxInternal2/SharedFoldersEnableSymlinksCreate/vagrant","1"] end 

Next, you will need to separate your provisioning script in two parts that will run the usual apt / git / any material with root privileges ... and the other, which will work as the default user "tramp"

 $rootScript = <<SCRIPT # some rooty stuff (just don't forget to include git and curl here) SCRIPT ## This is the script that will install nvm as the default 'vagrant' user $userScript = <<SCRIPT cd /home/vagrant # Installing nvm wget -qO- https://raw.github.com/creationix/nvm/master/install.sh | sh # This enables NVM without a logout/login export NVM_DIR="/home/vagrant/.nvm" [ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh" # This loads nvm # Install a node and alias nvm install 0.10.33 nvm alias default 0.10.33 # You can also install other stuff here npm install -g bower ember-cli SCRIPT 

Finally, you need to say a tramp in order to run the second script only with user rights (as almost completely without documents here ):

 config.vm.provision "shell", inline: $rootScript config.vm.provision "shell", inline: $userScript, privileged: false 

That should do. Not really, but it works.

Look here for working sense and good luck!

+13
source

Source: https://habr.com/ru/post/1207646/


All Articles