npm ERR! EPROTO: protocol error, symlink '../@babel/parser/bin/babel-parser.js' -> '/home/vagrant/code/proadco.test/node_modules/.bin/parser'

Viewed 17678

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: fsevents@1.2.9 (node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.9: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: minimist@1.2.0 (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?

6 Answers

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.

For Windows Host

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

Not for Windows Host

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.

What worked for me was this. In the Homestead environment I used:

sudo su

then run again

npm install

i was fighting this case for days, finally i ve installed all the node module dependencies "using IDE" and its fixed

As mentioned by

i was fighting this case for days, finally i ve installed all the node module dependencies "using IDE" and its fixed

ulas korpe

My problem was with laravel/homestead and win11 - they seemd to have conflicts and I couldn't get around them via vagrant. But the genious idea of going local, and editing files outside of the VM ( in the shared folder ) is the perfect solution.

So yeah, running

npm install

locally not on a VM solves this problem for me.

Related