24
votes

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!

6

6 Answers

52
votes

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!

7
votes

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

2
votes

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

npm install --no-bin-links
1
votes

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.

1
votes

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
votes

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