Is there a solution for npm install error in Laravel Homestead?
I have grappled with the exact same issue for the last two days, except that I run on macOS (10.14). Using yarn
instead of npm
has finally allowed me to compile properly (see the doc for installing the package: https://yarnpkg.com/lang/en/docs/install/#alternatives-stable). It is a package manager that can use the same package.json
entry point as npm
, and you can simply try to run yarn install
to perform the same action as npm install
(for more in depth comparison between the commands, you can check out this link: https://yarnpkg.com/lang/en/docs/migrating-from-npm/). To be sure, it does not fix the main issue with npm, but at least it should allow you to work on your project while waiting for a more sound answer.
What I've done to circunvemt this error is to npm install
in the host-machine rather than on the guest through vagrant ssh
. It seems that it's a problem with Windows locking the files from what I've researched. What I've done to bypass it, is:
vagrant halt
- Inside your host (Windows), go to the shared folder for the website that you set-up in the
homestead.yaml
file. - Open
cmd
orgit bash
(as admin) from inside the folder (Shift+Right click orcd
into it) and runnpm install
. - Voilà
vagrant halt
then just run npm, install && npm run dev, and it worked for me