Homestead: Using npm on windows host will cause symlink errors

Created on 14 Jul 2017  Â·  7Comments  Â·  Source: laravel/homestead

Please note that the Homestead issue tracker is reserved for bug reports and enhancements. We are not always able to debug Vagrant, Provider or Operating System issues but will do our best to help. Thank you!

Versions

  • Vagrant: Run vagrant -v to show the version.
    Vagrant 1.9.2

  • Provider: Virtualbox, VMWare or Parallels and it's version.
    VirtualBox

  • Homestead: Run homestead --version to show the version.
    5.3.2

Host operating system

This is the operating system that you run locally.

Windows 10 64 bit.

Homestead.yaml

---
name: homestead7
ip: "192.168.10.10"
memory: 2048
cpus: 1
provider: virtualbox


authorize: /Users/Jonathan/Dropbox/Documents/SSH-Keys/Homestead/homestead.pub

keys:
    - /Users/Jonathan/<snip>/private.key

folders:
    - map: /Code
      to: /home/vagrant/Code

sites:
    - map: new.app
      to: /home/vagrant/Code/new.app/public


databases:
    - homestead

ports:
     - send: 80
       to: 80
     - send: 443
       to: 443

Expected behavior

Before you begin

Make sure you have started vagrant on windows using a normal user. ie, you have NOT selected to run as administrator

My npm verison is 5.0.3 (but has existed in all versions)

1) Create a new folder like /code/npmBug

2) Create a package.json file in it with the following

{
  "devDependencies": {
    "babel-cli": "^6.24.1"
  }
}

3) Save it then run npm install

What should have happened?

21:43:08 ✔ vagrant@homestead $ npm install

> [email protected] install /home/vagrant/Code/npmbug/node_modules/fsevents
> node install

npm notice created a lockfile as package-lock.json. You should commit this file.
npm WARN npmbug No description
npm WARN npmbug No repository field.
npm WARN npmbug No license field.

added 182 packages in 35.105s

Actual behavior

What actually happened?

[~/Code/npmbug]
22:01:19 ✔ vagrant@homestead $ npm install
npm WARN npmbug No description
npm WARN npmbug No repository field.
npm WARN npmbug No license field.
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: [email protected] (node_modules/fsevents/node_modules/node-pre-gyp):
npm WARN enoent SKIPPING OPTIONAL DEPENDENCY: ENOENT: no such file or directory, rename '/home/vagrant/Code/npmbug/node_modules/fsevents/node_modules/node-pre-gyp' -> '/home/vagrant/Code/npmbug/node_modules/fsevents/node_modules/.node-pre-gyp.DELETE'

npm ERR! path ../babel-cli/bin/babel.js
npm ERR! code EPROTO
npm ERR! errno -71
npm ERR! syscall symlink
npm ERR! EPROTO: protocol error, symlink '../babel-cli/bin/babel.js' -> '/home/vagrant/Code/npmbug/node_modules/.bin/babel'

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/vagrant/.npm/_logs/2017-07-13T22_02_13_998Z-debug.log

However:

If we start Vagrant as a windows admin account (eg open command prompt by right clicking on cmd icon and selecting Run as administrator, then start vagrant/homestead as normal)

None of these issues then appear. All npm commands work and symlinks are created during the install process successfully.

I did attempt to use this PR: https://github.com/laravel/homestead/pull/609 and ran vagrant as a normal user. However when running the command npm install it again produced a symlink error and installation was a failure.

Because of this, I'm not sure if there's any real fix for windows hosts.

References

Are there any other GitHub issues (open or closed) that should be linked here?
For example:

Basically there no need for me to write anything else as it's all covered here in the issue below!

https://github.com/npm/npm/issues/7308 but more specifically, everything after:
https://github.com/npm/npm/issues/7308#issuecomment-84214837

Most helpful comment

npm install --no-bin-links as a workaround resolved the issue for me.

All 7 comments

Thanks for taking the time to write this up. As I expected this is caused by not running the console application as administrator (therefore running vagrant as Administrator). There isn't anything we can do to fix this for windows users (and not make a change that would affect all platforms as the previous PR showed).

Sounds like the best advice is to run Vagrant as an administrator on Windows, or use the Linux subsystem to create your projects instead of doing it in Homestead.

On Windows use Babun

npm install --no-bin-links as a workaround resolved the issue for me.

The problem is that npm install is trying to create symlinks on an NTFS file system, which doesn't have that feature. So with the --no-bin-links option it will copy all references to the same node projects as needed.

By the way, if you already ran npm install, you have to delete the node_modules directory (rm -rf node_modules) before running npm install --no-bin-links or otherwise it'll still fail at the same place.

I've updated the documentation to add a note about this for others
https://github.com/laravel/docs/pull/5456

Just in case anyone else stumbles on this, running npm v6.14.3 I also had to clear the cache to get the installer working correctly:

rm -rf node_modules
npm cache clean --force
npm install --no-bin-links
Was this page helpful?
0 / 5 - 0 ratings

Related issues

mattmcdonald-uk picture mattmcdonald-uk  Â·  3Comments

leandroruel picture leandroruel  Â·  4Comments

bironeaj picture bironeaj  Â·  3Comments

mtpultz picture mtpultz  Â·  4Comments

dorinniscu picture dorinniscu  Â·  4Comments