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

mstnorris's avatar

gulp watch doesn't "watch" it just finishes

When I run gulp watch it doesn't "watch" the files for changes. It runs as it should but it finishes meaning I have to run it again manually.

I'm using:

Laravel: Laravel Framework version 5.1.2 (LTS)
Gulp: CLI version 3.9.0 and Local version 3.9.0
~/Code/laravel/project $ gulp watch
[14:51:42] Using gulpfile ~/Code/laravel/project/gulpfile.js
[14:51:42] Starting 'default'...
[14:51:42] Starting 'scripts'...
[14:51:42] Merging and Minifying: resources/assets/js/vendor/jquery.js, resources/assets/js/vendor/bootstrap.js, resources/assets/js/vendor/lettering.js, resources/assets/js/vendor/socket.io.js, resources/assets/js/vendor/textillate.js, resources/assets/js/vendor/vue.js, resources/assets/js/vendor/vue-marked.js, resources/assets/js/vendor/vue-resource.js, resources/assets/js/app.js
[14:51:42] Finished 'default' after 79 ms
[14:51:42] File not found: resources/assets/js/vendor/vue-marked.js
[14:51:48] Finished 'scripts' after 5.84 s
[14:51:48] Starting 'styles'...
[14:51:48] Merging and Minifying: resources/assets/css/vendor/animate.css, resources/assets/css/vendor/bootstrap.css, resources/assets/css/vendor/font-awesome.css, resources/assets/css/style.css
[14:51:48] Finished 'styles' after 243 ms
[14:51:48] Starting 'version'...
[14:51:48] Versioning: public/css/all.css, public/js/all.js
[14:51:48] Finished 'version' after 21 ms

Anyone else having these issues? Or know of something I need to do in order for gulp to "watch" my files.

0 likes
27 replies
jekinney's avatar

I get the same out put, but it doesn't exit it's still watching. Weird...

mstnorris's avatar

I thought it could be to do with not being able to find vue-marked.js that I hadn't yet copied across but that didn't solve it. It is really annoying.

mstnorris's avatar

@jekinney I've just downloaded the polymer-starter-kit and that too uses gulp to compile the files and start a server.

I did everything correctly and lastly run gulp serve (to start the localhost server) only to watch the JavaScripts / CSS be compiled and then the script would finish and the server wouldn't be running.

I had a "light-bulb" moment and thought maybe I should try sudo gulp serve and it worked!!

I wondered if that was the issue with gulp watch which it is.

So, I have another question (open to anyone): how do I give gulp the correct access so I don't have to use sudo each time?

1 like
lmtorres's avatar

I'm having the same issue, except that sudo didn't fix it. It just stopped watching js files, I recently updated Elixir to add multiple browserify bundles. It used to work when I only had 1 browserify bundle, now it just doesn't watch for changes, even though the command doesn't exit, it stays running as if it were watching. It DOES watch for new style changes though, so I really have no idea what's going on.

EDIT: fixed by running gulp watch on local machine instead of Homestead...

devinfd's avatar

Yea, I've also been experiencing some odd watch behavior over the past week. Especial since the browserify mix switched to using watchify. Watchify is great but something has gone amiss. Specifically, now when I run gulp watch my js bundles are all concatenated into one file rather than their separate bundles and just as @mstnorris has described the watch ends.

1 like
mstnorris's avatar

Has anyone got any input on this? I've just started a new project, completely clean install, trying to run

gulp watch

gulpfile.js

var elixir = require('laravel-elixir');

elixir(function(mix) {
    mix.phpUnit();
});

and it still finishes!

gwp's avatar

@mstnorris Is this using homestead or is this using gulp in a local folder? You are running Mac OS X if I recall correctly?

1 like
mstnorris's avatar

@gwp I am running Mac OS X 10.10.4, Laravel Homestead 2.1.4, and Laravel 5.1.6.

I am running gulp watch from my Mac (host machine, NOT within Homestead).

lmtorres's avatar

@mstnorris does the command end or do you have to do ctrl + c to exit from it before you can run gulp watch again?

gwp's avatar

And are you using gulp from the local project or global?

Also, what version? (gulp -v)

mstnorris's avatar

@lmtorres the command ends itself and I can run gulp or gulp watch again. I've also tried this with the new gulp tdd and it still doesn't work.

mstnorris's avatar

@gwp which gulp returns /usr/local/bin/gulp which is the global installation. How do I change it to use the local installation?

Also, do I need to have it installed globally?

gwp's avatar

Okay I just did the following:

laravel new test-gulp
cd test-gulp
npm install
gulp watch

with gulpfile.js

elixir(function(mix) {
    mix.sass('app.scss');
});

…and it works as expected.

When I change gulpfile.js to:

elixir(function(mix) {
    mix.phpUnit();
});

…it stops as you describe after running once. Is this the same for you, or is it for any mix.* command?

Regarding global vs local gulp, the global gulp will look for a locally installed (folder specific) gulp to pass the commands to, which should work fine. In fact, it is probably better to not have it globally installed, and install it per-project.

mstnorris's avatar

It doesn't watch at all, whether I use mix.sass('app.scss'); or mix.phpUnit(); they both just finish after running once.

mstnorris's avatar

Any new updates on this? I've started a new project and almost a clean install of Laravel 5.1.6.

gulp -v
[15:18:43] CLI version 3.9.0
[15:18:43] Local version 3.9.0

gulp watch still finished after the first run.

mstnorris's avatar

Still no resolution on this. It's a real pain to keep running gulp every time a small change is made.

Laravel 5.1.10
npm 2.11.3
gulp CLI version 3.9.0, Local version 3.9.0

drewjo's avatar

I'm having a similar issue. I run gulp watch, and I have to ^C to get out of it, but it never does anything when files are changed.

Laravel 5.1.10 npm 2.11.3 gulp CLI version 3.9.0, Local version 3.9.0

[13:04:04] Using gulpfile ~/git/project1/gulpfile.js
[13:04:04] Starting 'watch'...
[13:04:04] Finished 'watch' after 13 ms
mstnorris's avatar

Interesting that it isn't the same issue though. Mine doesn't "watch", it just runs the once. I haven't tried it for a while now and I haven't updated it nor tried it with a clean install for some time. I'll do that tomorrow and report back.

Thanks for taking the time to share your issues, hopefully we can get a fix to this soon (or at least get to the bottom of what is causing it).

PSMedia90's avatar

im having the same problem when i run "gulp watch"

Laravel Version 5.1.11 NPM -V 1.3.10 CLI Version 3.9.0 Local Version 3.9.0

"gulp watch" just sits there and does nothing put i can just run the "gulp command"

this started after update to Laravel 5.1.11. has me scratching my head so to speak.

parrker's avatar

I had the exact same annoying problem for a couple of days, and using sudo gulp watch worked for me. Using gulp on host machine (not Homestead) on a Mac OS X 10.11.2.

amaya007's avatar

it is really annoying that happened with everyone i guess i didn't have the vue-marked.js file. but i guess i'm wrong okay help me out i tried all solution available at here.

agorshechnikov's avatar

Greetings!

I've fixed this issue by discovering non obvious syntax error in my .scss file, like:

background: #fff {  
border: 1px solid #ccc;

Hope this will help to anyone.

Please or to participate in this conversation.