npm ERR! code ENOENT npm ERR! syscall open - laravel

I am trying to install npm in a laravel homestead folder but i get these error messeges.
error messages in terminal

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
type: "nfs"
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:
rm -rf node_modules
npm cache clean

In terminal from Homestead directory type vagrant plugin install vagrant-winnfsd. After installing that plugin as said above add to Homestead.yaml file line type: "nfs" streight below folders mapping so it looks like:
folders:
- map: ~/your_path/projects_folder
to: /home/vagrant/code
type: "nfs"
Then in terminal from Homestead directory vagrant reload --provision, vagrant ssh, cd to your project folder cd code/project. If installation failed before you can delete node_modules folder with rm -rf node_modules and npm install & npm run dev again.

Related

Azure pipelines working directory pointing two different places

Hi Everyone I have a question related to the pipeline.workspace variable.
In the example below i have set pipeline.workspace as the working directory and as paths for a cli command.
Npm install creates folders under /home/vsts/work/node_modules/
while the next command when i use pipeline.workspace it points to ./home/vsts/work/1/
Am I doing something wrong? or is something up?
- task: Bash#3
displayName: 'Publish Sentry'
inputs:
targetType: 'inline'
script: |
npm install #sentry/cli
.$(Pipeline.Workspace)/node_modules/.bin/sentry-cli releases --org --project new "$(Build.BuildNumber)" --finalize
workingDirectory: "$(Pipeline.Workspace)"
The node_modules folder is pre-generate that may contains some global packages. It is not generated by the npm install command in the script. This situation exists on Microsoft-hosted Ubuntu agents and Microsoft-hosted macOS agents.
When executing the npm install command to install packages locally, there are few points you need to pay attention to :
If no node_modules folder is existing in current working directory, and also no node_modules folder is existing in any parent directory of current working directory, the npm install command will generate the node_modules folder in current working directory and install the packages into this node_modules folder.
If no node_modules folder is existing in current working directory, but the node_modules folder is existing in parent directory, the npm install command will install the packages into the existing node_modules folder in the closest parent directory.
For example, there are the following paths:
/root/dir1/node_modules
/root/dir1/dir2/node_modules
/root/dir1/dir2/dir3
When executing the npm install command in the directory "/root/dir1/dir2/dir3", the packages will be installed into "/root/dir1/dir2/node_modules".
If the node_modules folder is existing in current working directory, regardless of whether the node_modules folder is existing in parent directory or not, the npm install command will install the packages into node_modules folder in current working directory.
For example, there are the following paths:
/root/dir1/node_modules
/root/dir1/dir2/node_modules
/root/dir1/dir2/dir3/node_modules
When executing the npm install command in the directory "/root/dir1/dir2/dir3", the packages will be installed into "/root/dir1/dir2/dir3/node_modules".

Error executing NPM INSTALL inside Homestead

We are developing an app in Laravel, and we created a new project, we have an error when trying to run NPM INSTALL inside Homestead.
**We are using:
Vagrant 2.2.9
NPM 6.14.10
Node 12.20.0
The last homestead version
We tried:
Deleting node_modules
Deleting composer.json.lock
Cleaning cache
Reinstalling the virtual machine with the last version
And other stackoverflows.
But the solutions dont work.
And we can't run npm install. The error is: no such file or directory open 'home/vagrant/code/testing/node_modules/yargs/node_modules/cliui/package.json.3695679736' This is related to npm not being able to find a file.
Can you help me please?
Thanks.
I found the solution, you need to:
install NFS in your local machine (sudo apt-get install nfs-kernel-server) if u are using ubuntu, check how to do it in windows.
add type: "nfs" in your Homestead.yaml after folder mapping
vagrant reload --provision
And thats it. trying npm install now is working ok!

Issue with npm install using homestead on windows

[Edit:Solved]
Its working now with NFS protocol.
From Homestead directory command vagrant plugin install vagrant-winnfsd adds nfs support to vagrant on windows.
In Homestead.yaml file line type: "nfs" below folder mapping section.
vagrant reload --provision restars box and everything works fine.
Im having problem with npm. I know there are other ways to install npm, but Im trying to find solution to install it that way - using vagrant ssh.
Windows 10 Home
Vagrant 2.2.10
Virtual Box 6.1.14
Homestead 11.x
Using ssh Im trying to 'npm install' from fresh project directory. During installations Im having error -2:
npm ERR! enoent ENOENT: no such file or directory, open '/home/vagrant/code/project/node_modules/webpack-dev-server/node_modules/ansi-regex/package.json.360296631'
npm ERR! enoent This is related to npm not being able to find a file.
To be clear - npm is installed on ubuntu which is part of Homestead - runned on VM with vagrant using virtual box.
Hope some1 solved that issue. I found it could be a problem with some windows permissions. Im running everything as admin, was trying 'npm install --force' etc etc.
Thanks.
since you're using vagrant ssh, please try sudo npm install

Cannot compile Laravel assets on new Homestead install

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
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
type: "nfs"
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:
rm -rf node_modules
npm cache clean

Gulp didn't install on Laravel Homestead VM (from Windows) and no node_modules folder exists in the directory with package.json?

I got Laravel Homestead up and running, except when I issue this ssh command:
gulp
I get this error:
Local gulp not found in ~/projects/laravel
Try running: npm install gulp
That's when I noticed there was no node_modules folder at all in this directory. Weird. Is this an issue where the paths were too long for Windows when I did a vagrant up? Since the host machine for this VM is Windows and I'm sharing folders with my VM (actually I'm not, but rather I'm using phpStorm's sync so that pages will load faster on the VM), when I do a npm install am I still going to encounter the problem? Hmm...I guess Taylor Otwell is using a Mac for development. Anybody have a solution to this?
You should first install node in your local machine.
Then, navigate to your project folder and delete node_modules directory.
Run on your local machine inside project directory:
npm install gulp --save-dev
Solved it!
Yes it appears to be that some of these paths from these package installs are too long for Windows. This means you can only install the gulp package after your VM is up. Here's what I did: (I also include a step for use with phpStorm already (since it will keep server pages loading faster on the VM)
SSH into the VM and create a folder called node_modules in your project's directory (the directory where package.json is).
In phpStorm, go to File > Settings > Build, Execution, Deployment > Deployment and click on the Excluded Paths tab. Click the Add deployment path button and add the folder node_modules from step 1.
SSH back into the VM and in your projects folder (should be directory folder with package.json) and run this command: npm install. This will install all packages listed in your package.json file locally to the directory you are in, and will put the necessary files into the folder node_modules.
Now run the gulp command: gulp
UPDATE:
If you really prefer file-sharing through a mounted folder, then I've created a Gist that will guide someone through all the challenges I faced and had to resolve, including how to successfully run npm install in the guest environment:
Laravel Homestead for Windows (includes fixes)

Resources