Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Windows Symlinks #26

Closed
nickfederighi opened this issue Dec 29, 2016 · 6 comments
Closed

Windows Symlinks #26

nickfederighi opened this issue Dec 29, 2016 · 6 comments

Comments

@nickfederighi
Copy link

nickfederighi commented Dec 29, 2016

Just wanted to report an issue that I had with this on Windows and Homestead that others might come across. It may make sense to include this somewhere in the documentation (maybe even the Homestead documentation, as well).

For windows users using Homestead, npm cannot make symlinks unless the command prompt is run with administrator privileges. Typically, to get around this, you can run npm install --no-bin-links to force no symlinks. That works well, for most everything. However, because the Laravel Mix npm scripts require the node_modules/.bin directory to contain the symlinks, Windows users in non-elevated sessions will see a cross-env: command not found error.

In Summary: if you're a windows user with homestead, you'll have make sure to run vagrant up and npm install in a command prompt with admin privileges.

@QWp6t
Copy link
Contributor

QWp6t commented Dec 29, 2016

Out of curiosity, is this issue resolved with yarn add cross-env? (or npm i cross-env since that seems to be your thing)

Also, what version of npm are you using? I'm just wondering so I can see if I can reproduce this issue. (I'm also a Windows user, so this concerns me.)

@nickfederighi
Copy link
Author

No, unfortunately, adding or installing cross-env through yarn or npm doesn't solve the issue. I've tried it with both. The package will show up in the node_modules folder, but there won't be a link in the node_module/.bin folder, which is why i believe it throws the error?

This is with the default npm version off a fresh Homestead install (npm -v is 3.10.8). I've updated NPM and node to more current versions and also get the same issue. The only way to resolve this seems to be to vagrant up with admin rights and run the initial npm install with the same rights.

A few other caveats I've noticed:

  • Even in an admin-elevated session, yarn install will install all packages but throw errors on yarn run dev. Removing /node_modules and reinstalling with npm install then running npm run dev works fine...
  • There aren't any issues with cross-env in Homestead on Windows in folders that aren't mapped to the host machine. If you SSH into your Homestead box, make a new directoy and follow Jeffrey's instructions for a stand-alone project here, there are no issues. This is definitely related to the way that the Windows machine handles symlinks.
  • Running vagrant up as an administrator can cause the nuisance of not being able to open multiple vagrant ssh sessions at the same time.... An administor created vagrant box doesnt seem to be visible to other command prompt windows. Running vagrant ssh from another tab or window won't recognize the box that's currently running.

@QWp6t
Copy link
Contributor

QWp6t commented Dec 29, 2016

What I mean is: did you try specifying them as dependencies in your package.json file, instead of as sub-dependencies of laravel-mix.

Example:

yarn add laravel-mix 
:: ...
dir node_modules\.bin 
:: File Not Found
yarn add cross-env
:: ...
dir node_modules\.bin
:: 12/29/2016  03:09 PM               323 cross-env
:: 12/29/2016  03:09 PM               200 cross-env.cmd

@nickfederighi
Copy link
Author

Yes, I've tried it both ways. Specifying cross-env in the package.json file didn't have any different effect.

@PascaleBeier
Copy link
Contributor

Hey there, Windows 10 Homestead User as well. I cannot reproduce your issue in the first place.

Some hints:

  • Try updating VBox and vagrant and provision a fresh Homestead VM
  • Link the broken packages with npm link

Does that help?

@PascaleBeier
Copy link
Contributor

I just checked my Vagrantfile - pretty sure using NTFS solved my symlink problems :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants