Permalink
Browse files

This is a majorly important update.

It may not seem like it when checking out the code changes, but this update houses a huge fix for Windows based hosts. It is pretty well known that Windows paths cannot exceed ~260 characters, and this offers a huge problem for Node developers because of how npm handles nested modules. I have spent approximately 15 hours today (that is not an exaggeration), but I have finally built a solution to this problem.

After many, many hours of searching, I finally came across some npm/node/vagrant issues that talk about a particular error involving Windows hosts for vagrant machines that house Node code. It took a bit of time just to narrow down that the error I was receiving was caused by this problem, but I finally did. The official NPM, Node, and Vagrant issue threads did not have any viable solutions for fixing this problem in an automated sense, so I spent the rest of my day (now ending at about 4:00 AM), and I built a solution in Vagrant that overcomes this issue.

Feel free to check out this code. I'm sorry if my commit message is hard to follow, but I am tired. Good luck, and happy coding!
  • Loading branch information...
drmyersii
drmyersii committed Mar 18, 2015
1 parent d812297 commit bdf15f2f301e2b1660b839875e34f172ea8be227
Showing with 20 additions and 7 deletions.
  1. +10 −4 Vagrantfile
  2. +10 −3 provisioner.sh
View
@@ -6,6 +6,7 @@
# -*- mode: ruby; -*-
VAGRANTFILE_API_VERSION = "2"
MAX_MEMORY = 1024
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
@@ -16,11 +17,16 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.network :forwarded_port, guest: 1337, host: 1337
# set up synced folder
config.vm.synced_folder "./www", "/home/vagrant/www"
#config.vm.synced_folder "./www", "/home/vagrant/www"
# if you are using VirtualBox, uncomment the line below to allow symlinks in the shared "www" folder
#config.vm.customize ["setextradata", :id, "VBoxInternal2/SharedFoldersEnableSymlinksCreate/home/vagrant/www", "1"]
# settings for VirtualBox provider
config.vm.provider "virtualbox" do |v|
v.memory = MAX_MEMORY
v.customize ["sharedfolder", "add", :id, "--name", "www", "--hostpath", (("//?/" + File.dirname(__FILE__) + "/www").gsub("/","\\"))]
v.customize ["setextradata", :id, "VBoxInternal2/SharedFoldersEnableSymlinksCreate/home/vagrant/www", "1"]
end
# call provisioner shell script
# call provisioner shell scripts
config.vm.provision :shell, inline: "mount -t vboxsf -o uid=`id -u vagrant`,gid=`getent group vagrant | cut -d: -f3` www /home/vagrant/www", run: "always"
config.vm.provision :shell, path: "./provisioner.sh"
end
View
@@ -6,8 +6,8 @@ printf "Updating Box..."
# make sure the box is fully up to date
apt-get update
# uncomment the line below to allow the system to upgrade
#apt-get upgrade -y && apt-get dist-upgrade -y
# comment out the line below to disallow the system to upgrade
apt-get upgrade -y && apt-get dist-upgrade -y
printf "Adding MongoDB packages to apt..."
# import the public key used by apt
@@ -21,7 +21,13 @@ apt-get update
printf "Installing a few necessary packages..."
# install required packages
apt-get install -y git npm mongodb-org redis-server
apt-get install -y git nodejs nodejs-legacy npm mongodb-org redis-server
# make sure npm is up to date
npm install -g npm
# remove old hash for npm so bash will find the new version
hash -d npm
# backup mongodb-org config file
cp /etc/mongod.conf /etc/mongod.conf.backup
@@ -75,5 +81,6 @@ cp /home/vagrant/.bashrc /home/vagrant/.bashrc.backup
# if you don't want npm overridden, comment out the line below
echo "alias npm='npm --no-bin-links'" >> /home/vagrant/.bashrc
printf "Making sure ownership rights are correct in vagrant user directory..."
# make sure everything in the vagrant directory is owned by vagrant
chown -R vagrant:vagrant /home/vagrant --quiet

2 comments on commit bdf15f2

@LoveAndHappiness

This comment has been minimized.

Show comment
Hide comment
@LoveAndHappiness

LoveAndHappiness May 7, 2015

Hi drmyersii,

I have the same problem like you had, only that I am using a different vagrant box, namely the 3rd most popular box "homestead". (https://atlas.hashicorp.com/boxes/search?utm_source=vagrantcloud.com&vagrantcloud=1)

Since I just started using vagrant, I wonder I you have an easy solution for homestead?

I also opened a stackoverflow question here, because homestead on github does not allow the openning of issues:

http://stackoverflow.com/questions/30090691/configuring-homestead-to-work-for-windows-users

thanks.

LoveAndHappiness replied May 7, 2015

Hi drmyersii,

I have the same problem like you had, only that I am using a different vagrant box, namely the 3rd most popular box "homestead". (https://atlas.hashicorp.com/boxes/search?utm_source=vagrantcloud.com&vagrantcloud=1)

Since I just started using vagrant, I wonder I you have an easy solution for homestead?

I also opened a stackoverflow question here, because homestead on github does not allow the openning of issues:

http://stackoverflow.com/questions/30090691/configuring-homestead-to-work-for-windows-users

thanks.

@drm2

This comment has been minimized.

Show comment
Hide comment
@drm2

drm2 May 7, 2015

Owner

Hi there!

I'm glad to see you found my solution. :) I answered it on StackOverflow, so I hope that helps you out!

Owner

drm2 replied May 7, 2015

Hi there!

I'm glad to see you found my solution. :) I answered it on StackOverflow, so I hope that helps you out!

Please sign in to comment.