Not able to run 'npm install' on vagrant homestead

3.1k views Asked by At

I'm trying to install Gulp & Elixir on my Laravel project but I keep getting errors when I run 'npm install'. I've also tried 'sudo npm install' but no luck there.

My Node version is: 1.4.14

It switches between these two:

enter image description here

For this error there was a solution posted here: https://harvsworld.com/2015/how-to-fix-npm-install-errors-on-vagrant-on-windows-because-the-paths-are-too-long/

But this has not solved the issue seeing it still happens after following the steps.

I also sometimes get these errors (the list goes on...): enter image description here

Anyone know a solution? I haven't found anything yet after a couple hours of searching..

2

There are 2 answers

1
Pex On BEST ANSWER

After a long search I eventually found the solution. Seeing I'm using Homestead / Vagrant, I was using PuTTY. This was my first mistake. Just simply use Git Bash, just make sure you run it as an administrator & change the directory to your Laravel project.

The second thing you need to do is make sure you don't have a 'node_modules' file in your project. Just remove the files by doing:

rm -rf node_modules/

Followed by:

npm install

Everything should work now. It's a dumb mistake but hopefully through this post, people will not make the same one as I did and waste alot of time doing it..

Cheers!

0
Alex Kyriakidis On

You should first install node in your local machine.

Then, navigate to your project folder and run (again on your local machine!):

npm install gulp --save-dev