Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

roulendz's avatar

[L5] PROBLEM Installing nodejs, gulp and laravel-elixir on Homestead 2.0

All day today I was trying to install gulp, npm, nodejs, laravel-elixir on my Homestead 2.0 machine but no luck!

I pasted all my console please check, what could be wrong or maybe on Homestead it is IMPOSSIBLE to install gulp and all what is needed?

My console: http://pastebin.com/erTdYRsY

I have tried lot of things: sudo apt-get install -y nodejs

sudo apt-get install npm

sudo apt-get update

npm install -g express

sudo npm install -g express

sudo npm install gulp -g

sudo npm install

npm install gulp

install laravel-elixir

sudo npm install laravel-elixir

sudo npm cache clean

sudo npm update

0 likes
11 replies
sitesense's avatar

Ok... first of all, install node.js and related stuff, Elixir etc - on your local machine. The node modules will be copied from local to VM.

Then run gulp locally, this way you'll get the notifications on your local machine.

Composer, you can run on either local or VM. Artisan commands, I suggest you run on the VM, especially if it's anything to do with migrations or seeding, because the database only exists in your VM.

roulendz's avatar

Can you please write down all commands, what I should run in correct order to install all things be able to run gulp and bower for front end dependencies with laravel-elixir.

bashy's avatar
bashy
Best Answer
Level 65

This is all done via your computer (not the VM).

I use Homebrew to install programs (package manager for Mac): http://brew.sh

brew update && brew upgrade // if you already have it installed, you may want to update current installed packages
// install node.js
brew install node

// should have some versions returned
node -v
npm -v

// if you use SASS you'll need an older version of node.js (v0.10.*) for it to work.
npm install -g n // install node.js version switcher
n -v // to make sure it's installed
n ls // shows available versions
n 0.10.36 // switched to latest 0.10.* version (as of now)

npm install -g bower // install bower

// change directory and install gulp etc from the Laravel settings
cd folder/of/project
npm install
// do not run the above command with sudo. This messes things up.
// if it returns errors, you can do the following to solve it
npm config set prefix ~/npm
export PATH="$PATH:$HOME/npm/bin" // append to .bashrc or .zshrc or similar
3 likes
roulendz's avatar

Thanks guys, tomorrow evening I will try to do it step by step, thanks

wngreenway's avatar

I followed the instructions in the answer, except I used sudo when I ran the npm install, I then read the commented line under it. Is there anything I can do to fix it?

jcamomile's avatar

Running Homestead on Win7

I installed nodejs on local machine I ran npm install on project got bash: npm: command not found

So, what steps am I missing in getting this to work? Or should I go buy a Mac?

jcamomile's avatar

From what I am reading Homestead should include node.js

https://laravel.com/docs/5.3/elixir

"By default, Laravel Homestead includes everything you need; however, if you aren't using Vagrant, then you can easily install the latest version of Node and NPM using simple graphical installers from their download page."

I am running Homestead and Vagrant and Node.js is NOT included. So are there some uncommon situations where you have Vagrant and Homestead installed and ALSO need to add nodejs separately?

I wish there were some clear answers here, or at least that phrases like "it's so easy" and "you're gonna love it" would be used less when it comes to Homestead.

jcamomile's avatar

OK, here is the answer I was looking for..

If you have homestead and vagrant installed THEN run npm commands while in ssh.

So here is the bigger issue. I cannot tell from either the Laravel docs or laracasts when I am supposed to be in ssh to run commands or just using git bash without ssh. This is probably really simple but made really confusing because:

  1. lara-docs and casts assumes some knowledge many of us don't have
  2. I am missing something subtle in the docs or casts
  3. It is just one of those things that doc and cast writers forgot to specify
  4. it is part of a dark sinister plot to keep the uninitiated from learning this stuff (joking of course).
1 like
elasticsteve's avatar

You must have npm and nodejs installed on Windows (vagrant/homestead has it too). Also make sure both are in the Windows PATH (I think they are when you use their installers).

The trick is to know which command to run from where. Some things I have to run from the Windows terminal (I use the one inside PHPstorm), other you must use Git Bash (not very often), and then for others I use SSH Vagrant (also through terminal in PHPstorm).

I use Redis in Vagrant, so I have to do my redis-cli stuff from the Vagrant console, and I also have to do migrations from there. Most of the other things I can run on the Windows terminal. I run npm installs and updates from there as well as composer stuff. The issue is that on Windows there are tons of errors with npm. Sometimes you must run "npm install" twice to get it to finish and then some installers have not finish at all and you must complete them manually! This is not cool! I collected a list of things from the net how I deal with it all and it kind of works.

I run Mix from the Windows term.

Please or to participate in this conversation.