I'm attempting to execute npm install
in Git Bash client on Windows 8.1 but receiving the following error:
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: [email protected] (node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for [email protected]: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: [email protected] (node_modules/fsevents/node_modules/rc/node_modules/minimist):
npm WARN enoent SKIPPING OPTIONAL DEPENDENCY: ENOENT: no such file or directory, open '/home/vagrant/code/proadco.test/node_modules/fsevents/node_modules/rc/node_modules/minimist/package.json.737544774'
npm ERR! path ../@babel/parser/bin/babel-parser.js
npm ERR! code EPROTO
npm ERR! errno -71
npm ERR! syscall symlink
npm ERR! EPROTO: protocol error, symlink '../@babel/parser/bin/babel-parser.js' -> '/home/vagrant/code/mysite.test/node_modules/.bin/parser'
npm ERR! A complete log of this run can be found in:
npm ERR! /home/vagrant/.npm/_logs/2019-06-24T02_39_32_641Z-debug.log
Running npm install --no-bin-links
allows it to run successfully. But I don't full understand the consequences of this action. I believe it's saying "Don't create a symlink. Which is just a hack instead of resolving the root of the issue. But I've read that Windows doesn't support symlinks so it's impossible to solve.
Can someone explain what the consequences here are? And possibly how to overcome the root issue of symlinks?
What worked for me was to start Windows command prompt as Administrator and vagrant up
from there.
If Vagrant is already running, you will need to run vagrant suspend
before vagrant up
in your newly administrator-enabled command prompt.
The problem is that the Vagrant process needs administrator privileges to create symlinks
.
To get a rid of a previous unsuccessful installation, I ran npm clean-install
. npm run dev
still ends up with some errors but ui:auth
works.
In case you want npm to stop from creating symlinks for you, you can avoid that by
npm install --no-bin-links
more information about it on npm documentation https://docs.npmjs.com/cli/install.html
Note: This might have some unknown side effects, this methods worked fine for an application I was working on and when I encountered this issue. The side effects might be related to symlink, which npm is trying to create, and in the later phase of development it finds out that the symlink is not available.
This easy solution can exclude node_modules
folder from syncing with vagrant default sync provider (not rsync nor nfs).
Just vagrant ssh
onto your gest machine and execute these commands:
$ mkdir ~/project_node_modules
$ sudo mount --bind ~/project_node_modules /home/vagrant/code/project/node_modules
Warning! You need rsync
on both host and guest machines!
I found that is possible to exlude node_modules
folder from syncing with Windows filesystem in order to avoid the symlink problem.
In the Homestead Vagrantfile
this line will activate Rsync support for the folder you chose, but excluding right the node_modules
folder:
config.vm.synced_folder "C:\\path\\to\\project", "/home/vagrant/path/to/project", type: "rsync", :mount_options => ["dmode=777", "fmode=666"], rsync__exclude: ['node_modules/']
If it sounds difficult, you can follow the Homestead documentation at Configuring Shared Folder putting this in your Homestead.yaml
file:
folders:
- map: ~/code/project1
to: /home/vagrant/project1
type: "rsync"
options:
rsync__args: ["--verbose", "--archive", "--delete", "-zz"]
rsync__exclude: ["node_modules"]
Now, running command npm install
will be able to install all the project dependencies and command npm run dev
will be able to produce the mix manifest correctly.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With