Reputation: 63
All i'm trying to do is npm install command inside fresh installed Laravel app, but i keep getting errors.
After googling for two days and trying everything i found as a possible solution for npm install error i decided to try one more time reinstalling everything in hope that would fix my issue with npm install but unfortunately that didn't help either.
I tried deleting node_modules,
cleaning npm cache,
sudo npm install,
sudo npm install --no-bin-links,
updating node and npm but both were at latest version already,
changing VagrantFile based on some posts i've seen around internet(that never worked because than i'd get an error when i use vagrant up),
reinstalling everything,
running bash as admin,
I can't even remember everything I've done. This became really exhausing.
My log is 17k+ lines long. I'll just post last part where error happens.
17734 verbose stack Error: ENOENT: no such file or directory, open '/home/vagrant/code/vue-test/node_modules/yargs/node_modules/yargs-parser/package.json.2655513948'
17735 verbose cwd /home/vagrant/code/vue-test
17736 verbose Linux 4.15.0-54-generic
17737 verbose argv "/usr/bin/node" "/usr/bin/npm" "install" "--no-bin-links"
17738 verbose node v12.5.0
17739 verbose npm v6.10.1
17740 error path /home/vagrant/code/vue-test/node_modules/yargs/node_modules/yargs-parser/package.json.2655513948
17741 error code ENOENT
17742 error errno -2
17743 error syscall open
17744 error enoent ENOENT: no such file or directory, open '/home/vagrant/code/vue-test/node_modules/yargs/node_modules/yargs-parser/package.json.2655513948'
17745 error enoent This is related to npm not being able to find a file.
17746 verbose exit [ -2, true ]
My last hope is to ask if someone has a solution for this or i should just give up on Homestead.
Upvotes: 6
Views: 9727
Reputation: 11
I searched for solution for a long time and nothing worked.
What worked is installing nodejs on the host machine and then running npm install in the project folder and then running npm run ... in the guest machine's project folder
Upvotes: -1
Reputation: 21
vagrant halt
then just run npm, install && npm run dev, and it worked for me
Upvotes: 2
Reputation: 59
i tried everything.. the only thing that will work for me, is setting up a samba server on my linux box... from this i can edit the files directly on my windows machine..
hope this helps
Upvotes: 0
Reputation: 127
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
homestead.yaml
file.cmd
or git bash
(as admin) from inside the folder (Shift+Right click or cd
into it) and run npm install
.Upvotes: 6
Reputation: 156
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.
Upvotes: 14