# 'gulp watch' consistently fails [solved]

**URL:** https://discourse.roots.io/t/gulp-watch-consistently-fails-solved/3660
**Category:** sage
**Tags:** gulp
**Created:** 2015-05-01T18:39:42Z
**Posts:** 10

## Post 1 by @alwaysblank — 2015-05-01T18:39:42Z

Every time I try and run `gulp watch` on my brand-new project, I get the following error output:

```
[11:19:32] Using gulpfile /path/to/project/dev/site/public/wp-content/themes/project_name/gulpfile.js
[11:19:32] Starting 'watch'...
[11:19:32] Finished 'watch' after 78 ms
[BS] Proxying: http://dev.project_name
[BS] Access URLs:
 ----------------------------------
       Local: http://localhost:3000
    External: http://10.0.0.8:3000
 ----------------------------------
          UI: http://localhost:3001
 UI External: http://10.0.0.8:3001
 ----------------------------------
child_process.js:1155
    throw errnoException(err, 'spawn');
          ^
Error: spawn EACCES
    at exports._errnoException (util.js:746:11)
    at ChildProcess.spawn (child_process.js:1155:11)
    at Object.exports.spawn (child_process.js:988:9)
    at module.exports (/path/to/project/dev/site/public/wp-content/themes/project_name/node_modules/browser-sync/node_modules/opn/index.js:58:24)
    at Object.utils.open (/path/to/project/dev/site/public/wp-content/themes/project_name/node_modules/browser-sync/lib/utils.js:185:23)
    at Object.utils.openBrowser (/path/to/project/dev/site/public/wp-content/themes/project_name/node_modules/browser-sync/lib/utils.js:175:23)
    at EventEmitter.events.service:running (/path/to/project/dev/site/public/wp-content/themes/project_name/node_modules/browser-sync/lib/internal-events.js:40:23)
    at EventEmitter.emit (events.js:129:20)
    at /path/to/project/dev/site/public/wp-content/themes/project_name/node_modules/browser-sync/lib/browser-sync.js:246:19
    at /path/to/project/dev/site/public/wp-content/themes/project_name/node_modules/browser-sync/node_modules/async-each-series/index.js:15:40
```

(names changed to protect the innocent)

The vanilla `gulp` command executes fine, and I’ve removed /node\_modules + /bower\_components and re-run `npm install` and `bower install` twice, but I get the same problem every time.

I’ve tried this solution [Gulp Watch error on Ubuntu 14.04 [solved]](https://discourse.roots.io/t/gulp-watch-error-on-ubuntu-14-04-solved/3453) but it has no apparent effect.

If I remove the following section from my gulpfile, `gulp watch` works correctly (i.e. it watches my files and regenerates them if changes are made), but obviously does not reload the browser:

```
browserSync({
    files: [path.dist, '{lib,templates}/**/*.php', '*.php'],
    proxy: config.devUrl,
    snippetOptions: {
      whitelist: ['/wp-admin/admin-ajax.php'],
      blacklist: ['/wp-admin/**']
    }
  });
```

This leads me to believe the problem is solidly with BrowserSync, but I’m not familiar enough with how BrowserSync works to guess where it might be failing.

I’m running Ubuntu 14.04.2 LTS. My project is using a Vagrant box for a local server, but I’m running npm/gulp/etc on my command line, not in the Vagrant box.

node: v0.12.0  
npm: 2.9.0  
bower: 1.4.1  
gulp: 3.8.11

Let me know if there’s any more information I can provide to help debug this issue. Thanks.

---

## Post 2 by @joemaller — 2015-05-02T15:06:50Z

Can you post the output from `npm list --depth=0`? (mostly to see what version of BrowserSync is installed)

Does your project’s full path have any spaces or other non-ascii characters anywhere in it?

---

## Post 3 by @alwaysblank — 2015-05-02T18:31:25Z

Sure:

```
sage@8.2.0 /path/to/project/dev/site/public/wp-content/themes/project_name/
├── asset-builder@1.1.0
├── browser-sync@2.5.0
├── del@1.1.1
├── gulp@3.8.11
├── gulp-autoprefixer@2.2.0
├── gulp-changed@1.2.1
├── gulp-concat@2.5.2
├── gulp-flatten@0.0.4
├── gulp-if@1.2.5
├── gulp-imagemin@2.2.1
├── gulp-jshint@1.10.0
├── gulp-less@3.0.3
├── gulp-minify-css@1.1.0
├── gulp-plumber@1.0.0
├── gulp-rename@1.2.2
├── gulp-rev@3.0.1
├── gulp-sass@1.3.3
├── gulp-sourcemaps@1.5.2
├── gulp-uglify@1.2.0
├── imagemin-pngcrush@4.1.0
├── jshint-stylish@1.0.1
├── lazypipe@0.2.3
├── merge-stream@0.1.7
├── minimist@1.1.1
├── run-sequence@1.1.0
├── traverse@0.6.6
└── wiredep@2.2.2
```

There aren’t any spaces in the path, although the project is on a mounted NTFS drive. It’s mounted using the Ubuntu auto-mounting feature, and is mounted under my user (i.e. /media/user/driveName/), so I should have all necessary permissions.

---

## Post 4 by @joemaller — 2015-05-02T20:32:26Z

Ok, I’m thinking the mount is fine, otherwise the regular gulp tasks or npm would have failed too.

> [@benspants](#):
>
> ```
> at Object.utils.openBrowser (/path/to/project/dev/site/public/wp-content/themes/project_name/node_modules/browser-sync/lib/utils.js:175:23)
> ```

It looks like it might be bombing while trying to open a browser? :grimacing:

In your gulp ‘watch’ task, maybe try adding `open: false` to the `browserSync` config object. Like this:

```
gulp.task('watch', function() {
  browserSync({
    open: false,
    files: [path.dist, '{lib,templates}/**/*.php', '*.php'],
    proxy: config.devUrl,
```

Otherwise, check that you don’t have something already running on port 3000 or 3001. (or, longshot, port 8080, though [weinre](http://people.apache.org/~pmuellr/weinre/docs/latest/Home.html) isn’t enabled by default). Also that you have permission to open those ports.

---

## Post 5 by @kalenjohnson — 2015-05-02T20:38:23Z

Is it possible you have `gulp watch` running twice?

---

## Post 6 by @alwaysblank — 2015-05-04T02:06:29Z

This seems to have done the trick! Thank you!

---

## Post 7 by @joemaller — 2015-05-04T14:00:22Z

Great! Just for future google searches, which solution specifically fixed it?

---

## Post 8 by @alwaysblank — 2015-05-04T17:44:33Z

The solution was yours. More specifically, it twas to add `open:false` to my gulpfile, like so:

```
gulp.task('watch', function() {
  browserSync({
    open: false,
    files: [path.dist, '{lib,templates}/**/*.php', '*.php'],
    proxy: config.devUrl,
```

Thanks again!

---

## Post 9 by @Gavin_Jaynes — 2015-05-05T17:41:37Z

So happy to find this - have been dealing with this issue for days.

I’m on Windows 7 - this is the error:

```
[BS] Watching files...
events.js:85
      throw er; // Unhandled 'error' event
            ^
Error: spawn cmd ENOENT
    at exports._errnoException (util.js:746:11)
    at Process.ChildProcess._handle.onexit (chi
    at child_process.js:1144:20
    at process._tickCallback (node.js:355:11)
```

The strange part is it only happens on newer installs of Sage. Sage 8.0.1 works just fine.

Anyway - set to false fixes it. Good stuff.

---

## Post 10 by @kalenjohnson — 2015-05-05T17:45:02Z

It can quite possibly be related to the version of Browsersync that is getting installed.
