25

I'm building my first project in Laravel and trying to use Elixir, using homestead on Windows 8.1. I've hit the known npm/vagrant issue of too-long-path-names: https://harvsworld.com/2015/how-to-fix-npm-install-errors-on-vagrant-on-windows-because-the-paths-are-too-long/

So I made the one line edit recommended in that article (thank god for that guy), and then ran (with and without sudo): npm install --no-bin-links

It's moved me ahead so now I get two different kinds of errors: some 'Missing write access' errors, and a bunch of "EACCES" errors:

The error output gives me my next clue in the scavenger hunt (I think): Please try running this command again as root/Administrator

That brings me to this post, but the difference for me is there's no change even after I use sudo (or update my user permissions like so):

sudo chown -R $USER /usr/local

sudo chown -R $(whoami) ~/.npm

Update: then after the suggestion below I get EPROTO and EXTXTBSY errors (even after following the prompted suggestion to rename the npm-debug.log back: enter image description here

So I tried running gulp to see if it would give me clues, and error output had me do:

sudo npm rebuild node-sass

Running that gives me the same EPROTO and ETXTBSY errors, and the npm-debug.log file shows: error EPROTO: protocol error, symlink '../node-sass/bin/node-sass' -> '/home/vagrant/Code/Family-laravel/node_modules/laravel-elixir/node_modules/gulp-sass/node_modules/.bin/node-sass'

Then after working on some other stuff for an hour I came back fresh and redid these steps, this time getting way fewer errors:

  • sudo npm -g install npm@latest (fine)

  • sudo npm install --no-bin-links (just the ETXTBSY error and an error in plugin 'run sequence', in task 'sass')

  • sudo npm rebuild node-sass --no-bin-links (no errors!)

  • gulp (just one error: not found: notify-send)

Getting closer!

Community
  • 1
  • 1
Diane Kaplan
  • 1,626
  • 3
  • 24
  • 34

6 Answers6

54

I have been trying to figure out this problem for weeks. Here is what I did to make it work without using my host environment:

I updated node to the latest version in homestead according to nodesource.com:

sudo apt-get install --yes nodejs
curl --silent --location https://deb.nodesource.com/setup_4.x | sudo bash -

I updated npm to the latest version in homestead. This should be done after updating node:

sudo npm -g install npm@latest

I ran npm install in the laravel project directory. I also had to use force to get all of the dependencies to install:

sudo npm install --no-bin-links
sudo npm cache clear
sudo npm install --force --no-bin-links

I rebuilt node-sass according to a gulp error:

sudo npm rebuild node-sass --no-bin-links

During this whole process if something fails or after each install, i used:

sudo npm cache clear

My host is windows 10, with latest virtualbox, latest vagrant, latest homestead. I used git bash as administrator and ssh into vagrant using git bash.

So far I have only tested and confirmed that my gulp works. It is possible that other dependencies need to be rebuilt.

Hope this helps!

Adam
  • 556
  • 5
  • 3
  • Thank you!!! Those first couple links seemed to help, as I no longer get those 'EACCES' errors when I: sudo npm install --no-bin-links Ugh- but I should have left well enough alone because after doing the 'force' now I get new EEXIST and ETXTBSY errors :( – Diane Kaplan Oct 17 '15 at 18:01
  • Actually not: now the EACCES errors are just showing up in my npm-debug.log instead of in the prompt :/ – Diane Kaplan Oct 17 '15 at 18:16
  • I added the latest errors up above now- I knew from all the forum posts that getting elixir to work with my windows vm would be horrible, but yeah, it just keeps going :p – Diane Kaplan Oct 17 '15 at 18:53
  • And finally the answer to that last issue is here: gulp-notify: http://stackoverflow.com/questions/31431503/gulp-notify-error-in-notifier-error-in-plugin-gulp-notify-not-found-notify thank you, stackoverflow universe! – Diane Kaplan Oct 20 '15 at 11:26
  • sudo npm cache clear, solved the error keeps happening – astroanu Jun 17 '16 at 19:41
  • Very good answer. After searching for this problem for 6 hours I have found your answer and it work like charm. Thanks. – Ismail Zafar Nov 05 '16 at 08:17
  • Using `sudo npm` is the cause of your EACCES errors. You are the cause of your own problems. Use `sudo -H npm`. – Rich Remer Jul 29 '18 at 18:20
  • I found this article helpful: https://www.prolificinteractive.com/2015/01/21/getting-vagrant-nodejs-windows-play-well-together/ it worked for me. Maybe it will work for someone else as well. – Baljeet Bhinder Sep 04 '19 at 10:17
8

As many of you that are also setting up Homestead with Virtual Box...

After googling for a solution I decided to refer back to the Laravel Homestead documentation. Fortunately the solution was posted there:

https://laravel.com/docs/5.8/homestead#provider-specific-settings

You just need to add the following to your homestead Vagrantfile.

Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
(...)
    config.vm.provider "virtualbox" do |v|
        v.customize ["setextradata", :id, "VBoxInternal2/SharedFoldersEnableSymlinksCreate/v-root", "1"]
    end
(...)
end

IMPORTANT

Don't forget to provision as an administrator.

homestead up --provision

enter image description here

  • 1
    And from the year 2020, I just wanner say.... this just works! Adding that line to vagrant and running it as administrator `npm install` worked without any problems! – Patrick Rennings May 21 '20 at 06:48
  • I followed all these steps, but ```vagrant up --provision```. it still returns symlink error ```npm ERR! EPROTO: protocol error, symlink '../@babel/parser/bin/babel-parser.js' -> '/home/vagrant/Code/app_folder/node_modules/.bin/parser'``` This is Laravel 8 installation. – Sadee Jan 05 '22 at 14:03
  • @Sadee this was done a while ago. I have the impression that the current version might require a different approach. – Daniel Teleginski Camargo Jan 05 '22 at 16:59
  • Docs still have this listed as a fix. It doesn't do anything. – IGP Jan 31 '22 at 19:24
2

I had same problem. I did below. It works fine.

npm install --no-bin-links
Thavaprakash Swaminathan
  • 6,226
  • 2
  • 30
  • 31
1

The cause of your initial EACCES error was that you used sudo without using the -H option. NEVER use sudo npm. ALWAYS use sudo -H npm.

The instructions on the Internet everywhere (including NPM docs) are simply wrong.

Rich Remer
  • 2,123
  • 1
  • 21
  • 22
1

I solved my issue with the solution described here: https://www.prolificinteractive.com/2015/01/21/getting-vagrant-nodejs-windows-play-well-together/

The main trick was in:

vb.customize ["setextradata", :id, "VBoxInternal2/SharedFoldersEnableSymlinksCreate/path/to/guest/shared/directory", "1"]

Hope it helps someone

0

Here is how I solved the similar problem on VirtualBox:

# My Virtualbox image name "centos"
# My shared folder name: localdev
# My mounted directory name on virtualbox: /data

VBoxManage setextradata "centos" VBoxInternal2/SharedFoldersEnableSymlinksCreate/data 1
VBoxManage setextradata "centos" VBoxInternal2/SharedFoldersEnableSymlinksCreate/localdev 1

## see above how i added  image name with quotes + my folder names before 1

# I made sure I am running VirtualBox in Administrator Mode
# Boot up the VM and install this:

yum install yarn

# navigate to your code folder and run:

yarn install
Raja Amer Khan
  • 1,489
  • 10
  • 31