UPDATE 3 (LATEST)
Per suggestion below (from justanothereddie), configuring the drive as NFS fixed the problem. I am not sure why though, so will leave the question open for a few more days.
UPDATE 2
Just purchased a new MacBook Pro, but the problem remains. I can run an npm install
, provided the folder is not shared with the host. If it is shared with the host, it fails.
UPDATE 1
I have discovered that I can compile the Laravel assets if the drive I am working in is not shared with the host. I am running the distro’s VirtualBox package, which is 6.1.10. The latest release is 6.1.12, so perhaps that will fix it.
EDIT:
Originally I thought this problem was related to Laravel Jetstream, but I now see that it is related to Laravel more broadly. I have done a vagrant destroy
to remove the machine, and removed my Homestead directory, and reinstalled Homestead from scratch.
When I do a laravel new my_project
is installs fine, but as soon as I issue npm install
it fails with the same error message as below. I can not understand why no one else is reporting this. This is a very simple process which I have completed successfully about 100 times in the past, and the only thing I have not tried is new hardware or VirtualBox install.
ORIGINAL POST:
Did a vagrant destroy
a few days ago and installed the new Homestead on my Ubuntu host (20.04.1). Trying to install Jetstream for the first time, the inertia stack, with --teams
. Tried both the vagrant new
method, and the composer method. Failed both times with the following error.
npm ERR! code ENOENT
npm ERR! syscall open
npm ERR! path /home/vagrant/code/ftmv2/node_modules/yargs/node_modules/yargs-parser/package.json.1863223755
npm ERR! errno -2
npm ERR! enoent ENOENT: no such file or directory, open '/home/vagrant/code/my_test/node_modules/yargs/node_modules/yargs-parser/package.json.1863223755'
npm ERR! enoent This is related to npm not being able to find a file.
npm ERR! enoent
Removed the node_modules
directory and retried npm_install
, but outcome is the same.
- Jetstream Version: ^1.2
- Jetstream Stack: Inertia
- Laravel Version: ^8.0
- PHP Version: ^7.3
- Laravel Installer Version: 4.0.3
- NPM version: 6.14.8
2
Answers
Had the exact same issue on my MacBook Pro and added type: "nfs" to "folders" in my Homestead.yaml. Did a vagrant reload –provision and now npm will install and compile
I’ve suffered with this issue for a long time and it seems that the problem is using npm install as a vagrant user inside a laravel/homestead box so the main issue is one of permissions on a synced folder which is the main task of Homestead.yaml.
Referenced in: https://www.vagrantup.com/docs/synced-folders/nfs.html
There’s two solutions for this problem:
One will enable you to work from homestead normally, and the other is just like a patch of sorts.
Insert the next line just below your folder mapping on Homestead.yaml
Documentation of that here: https://laravel.com/docs/8.x/homestead
Next option is just working from your system, that has all permissions since it "owns" the folder in wich you are working.
Instead of executing npm install inside vagrant go to the folder in your system (your computer) and use the command from there.
If you need to clean install your project use: