Is there a solution for npm install error in Laravel Homestead?

喜夏-厌秋 提交于 2019-12-04 18:35:59

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:

  1. vagrant halt
  2. Inside your host (Windows), go to the shared folder for the website that you set-up in the homestead.yaml file.
  3. Open cmd or git bash (as admin) from inside the folder (Shift+Right click or cd into it) and run npm install.
  4. Voilà

I had the same problem

npm install --force

It works for me

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!