Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

  • Windows 10,
  • Homestead
  • VirtualBox 6.0.8,
  • Vagrant 2.2.5,
  • node v12.5.0,
  • npm v6.10.1

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.

like image 420
Mihajlo Škorić Avatar asked Jul 12 '19 23:07

Mihajlo Škorić


People also ask

Can I use npm with laravel?

Yeah, while npm run watch , just saving the your update on app. js will automatically re-compile app. js to add the module. Man!

How do I add Homestead to my Laravel project?

You can do this by cloning Homestead into your home directory. You can add it anywhere, but Laravel suggests for your to add it to your home directory (C:/users/your-user-name) since it can serve as a central location for all of your Laravel projects. For this, use Git Bash since it will automatically translate ~/Homestead to your home directory.

How to fix NPM install not working on my website?

There's a solution. Change your website folder location from Desktop or any to C:\ directly. Try again to npm install. It should work. :) Thanks for contributing an answer to Stack Overflow!

Does NodeJS come installed with npm?

I found the problem, NodeJS comes installed with NPM, but it's a pretty old version. Just did npm install npm -g to resolve my problems. Show activity on this post. These commands need to run on a fresh Laravel installation, otherwise you will face many errors. Want to get started fast?

How to get started with Laravel/UI composer?

These commands need to run on a fresh Laravel installation, otherwise you will face many errors. Want to get started fast? Install the laravel/ui Composer package and run php artisan ui vue --auth in a fresh Laravel application. Show activity on this post. Disable AntiVirus software, if you are running any also try to run npm cache clean.


1 Answers

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.

like image 137
Dorian Groll Avatar answered Sep 22 '22 06:09

Dorian Groll