npm install errors on vagrant/homestead/windows: EPROTO: protocol error, symlink
Asked Answered
J

6

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!

Janus answered 17/10, 2015 at 11:32 Comment(0)
J
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!

Jubbah answered 17/10, 2015 at 15:44 Comment(8)
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 :(Janus
Actually not: now the EACCES errors are just showing up in my npm-debug.log instead of in the prompt :/Janus
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 :pJanus
And finally the answer to that last issue is here: gulp-notify: #31432003 thank you, stackoverflow universe!Janus
sudo npm cache clear, solved the error keeps happeningWivinia
Very good answer. After searching for this problem for 6 hours I have found your answer and it work like charm. Thanks.Golgi
Using sudo npm is the cause of your EACCES errors. You are the cause of your own problems. Use sudo -H npm.Catenoid
I found this article helpful: prolificinteractive.com/2015/01/21/… it worked for me. Maybe it will work for someone else as well.Begot
K
9

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

Kampmeier answered 3/6, 2019 at 4:39 Comment(4)
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!Heidy
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.Earthen
@Earthen this was done a while ago. I have the impression that the current version might require a different approach.Kampmeier
Docs still have this listed as a fix. It doesn't do anything.Tefillin
C
2

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.

Catenoid answered 29/7, 2018 at 18:21 Comment(0)
C
2

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

npm install --no-bin-links
Catron answered 3/12, 2019 at 6:28 Comment(0)
B
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

Begot answered 4/9, 2019 at 10:18 Comment(0)
E
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
Ectomorph answered 2/9, 2020 at 23:2 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.