Support: Can't npm install within Vagrant machine (Laravel)

Created on 30 Jul 2020  路  14Comments  路  Source: EddieHubCommunity/support

Screenshot 2020-07-30 at 14 47 37

I'm trying to set up Passport with Laravel, I've followed along with the initial set up instructions from the docs. Once I've run -

php artisan vendor:publish --tag=passport-components and added the components to the resources/js/app.js file.

It then wants my to run 'npm run dev' however I just get a list of errors such as

'sh: 1: cross-env: not found
npm ERR! code ELIFECYCLE
npm ERR! syscall spawn
npm ERR! file sh
npm ERR! errno ENOENT'

question solved

Most helpful comment

Ok thanks. I tried many things, such as clearing the npm cache and re-installing many times but no joy. Then I deleted the package.json and couldn鈥檛 seem to recover the VM...

So at the point of no return I鈥檝e started again in another project and I seem to have it working now. Thanks for all your help!

All 14 comments

@natelloyd1 can you share what you have in the package.json file

Screenshot 2020-07-30 at 14 57 23

@natelloyd1 ahh, [adds some context here, this is a Homestead VM]

you need to be in the directory where the site is, the ENOENT suggests it can't find that file,
you'll find this in your homestead yaml it will generally be a case of switching to /mnt/something, /var/www/, /srv/ something

I think there are a few issues, but lets start off with issue 1 as others might become less of an issue later on.

npm install can not find package.json, you need to run the command in the same directory

OK, so it looks like it is in the same directory that I'm running the command in, see img.
Screenshot 2020-07-30 at 15 08 08

Oh sorry, just seen @stemount 's comment. Hang on.

This file path here? Looking now.
Screenshot 2020-07-30 at 15 14 10

I found another issue similar to yours.

Does providing the --no-bin-links option to npm install solve your issue?
_Originally posted by @goloroden in https://github.com/npm/npm/issues/7308#issuecomment-73489075_

Delete node_modules directory and try this command npm install --no-bin-links

thanks @alrifay. Didn't seem to work for me, see below -
Screenshot 2020-07-30 at 17 01 52

Destroying your Homestead box and recreating it may help, NFS may have fallen over here, so you can restart NFS and maybe the machine. An off and on job hopefully...

I remember from my time with vagrant many years ago, if commands were mix (run on local and in vm), then it would cause the project to break.

I think the issue is in the path because you are using window.

I found this in Laravel documentation - homestead:

Windows users should not use the ~/ path syntax and instead should use the full path to their project, such as C:\Users\user\Code\project1.

Ok thanks. I tried many things, such as clearing the npm cache and re-installing many times but no joy. Then I deleted the package.json and couldn鈥檛 seem to recover the VM...

So at the point of no return I鈥檝e started again in another project and I seem to have it working now. Thanks for all your help!

On another project now and ran 'npm install and npm run dev' within the directory - got errors.

Then I tried 'npm install', closed VS Code, then went back into the directory and successfully compiled the project with 'npm run dev'.

Not sure this will help anyone but I think it helped me.
Screenshot 2020-08-03 at 13 55 22

Was this page helpful?
0 / 5 - 0 ratings

Related issues

plazzy99 picture plazzy99  路  4Comments

mohit01-beep picture mohit01-beep  路  4Comments

BhuvaneshHingal picture BhuvaneshHingal  路  3Comments

AllanRegush picture AllanRegush  路  4Comments

schmelto picture schmelto  路  5Comments