gulp icon indicating copy to clipboard operation
gulp copied to clipboard

Add note about node >14 in gulp.watch documentation

Open nicolashenry opened this issue 3 years ago • 16 comments
trafficstars

Describe your idea for a new feature

Just add a small warning here https://gulpjs.com/docs/en/getting-started/watching-files about NodeJS version about Gulp not supporting NodeJS >= 14 for watching files.

Explain the problem your idea is trying to solve

I have multiple co-workers wanting to use this gulp feature and they are all missing the fact that this is not compatible with current LTS versions of NodeJS. So it could help to prevent users that this feature is not available for recent versions of NodeJS.

How will it benefit gulp and its users?

I think it will help users to not have to search in closed issues or discussions to have this information. I think this is reasonable since Gulp seems not going to be updated soon.

nicolashenry avatar Nov 29 '21 16:11 nicolashenry

You can also just disable fsevents in the options to watch. I think the warning should suggest that.

phated avatar Nov 29 '21 17:11 phated

Hi @nicolashenry,

We are planning to migrate from node 10 to node 16, Is this statement true that i gulp.watch is not supported in node > 14 ?

Actually my changing are not getting reflected in browser even with node 13 & Gulp 4, Can you please help me on this ?

anubajaj23 avatar Jan 20 '22 07:01 anubajaj23

@anubajaj23 gulp.watch is using an old and deprecated version of chokidar but kept for compatibility with old node versions. I chose to use directly chokidar with the latest version instead of using gulp.watch.

nicolashenry avatar Jan 21 '22 16:01 nicolashenry

Are there any plans for GulpJS to add support for chokidar 3 that supports NodeJS 14+? Security support for NodeJS 12 ends April 30, 2022

patrickcate avatar Feb 10 '22 19:02 patrickcate

@phated Do you know when gulp 4 will use the latest version of chokidar?

Adstokoe19 avatar Feb 14 '22 15:02 Adstokoe19

gulp.watch is using an old and deprecated version of chokidar but kept for compatibility with old node versions

Seems like it's time to just push to a new major version, node 16 is considered stable so why not target it?

Also looks like last commit was 9 months ago... is this library maintained anymore?

jpike88 avatar Mar 28 '22 17:03 jpike88

@jpike88 kindly buzz off if you don't understand how semver and dependencies work. We're actively working on the required changes for v5.

phated avatar Mar 28 '22 18:03 phated

@phated Do you know when gulp 4 will use the latest version of chokidar?

Sometime around ¯\_(ツ)_/¯ I believe. Take a look at how many of the closed issues are about some dependencies being outdated. And how many years ago they started appearing.

Atulin avatar May 06 '22 08:05 Atulin

With npm version 8+ one can add overrides section to package.json

  "overrides":{
    "chokidar":"^3.0.0",
    "glob-stream":"^7.0.0",
    "glob-parent":"^6.0.0",
    "micromatch":"^4.0.0"
  },

Which resolves the issue for me. Also one can fight vulnerable packages presence in package.lock.json

Alexander-Taran avatar Jun 05 '22 13:06 Alexander-Taran

I'm always using the latest version of node (currently 18.3.0) and haven't had issues with gulp watching files... I did find I needed to declare individually watched files in a weird way however, and maybe that's a result of the node 14+ issue? On the chance that this is the case, this is what I had to do:

  • For a single file like resources/js/app.js the watch call looks like gulp.watch("resources/js/**/app.js" (the downside is that this will catch every file named app.js at that directory or deeper)
  • For any files at a directory level or deeper, follow the same logic (this is how you'd want to declare that anyway): app/**/*.php

If you want to test and see it working without setting a project up you can check out my website bootstrap template here: https://github.com/prurigro/hypothetical

prurigro avatar Jun 14 '22 01:06 prurigro

@prurigro I think chokidar was developed for macOS primarily as it's author states in https://paulmillr.com/posts/chokidar-3-save-32tb-of-traffic/ So I think v2 of it is not working on macOS with node -v ≥ 14

Alexander-Taran avatar Jun 14 '22 12:06 Alexander-Taran

@Alexander-Taran That's a good point as I do use linux. That said, I just checked with my coworker who uses macos and he says gulp watch is working correctly for him with my template.

Edit: and he's using node v15.5.1

prurigro avatar Jun 14 '22 19:06 prurigro

On a project (with multiple themes) i've been working on, i'm using node v14.19.0 (MacOS) and my gulp watch appears to be working fine 👀

We have an object of theme name + path, and have this inside of a loop, looping over each theme to set the watch tasks (yes, it's a bit nasty).

themes.forEach(function(theme) {
  gulp.task(`watch:sass:${theme.name}`, gulp.series(`compile:sass:${theme.name}:watch`, function() {
    var watchList = [
      `${theme.path}/sass/**/*.scss`,
    ];
    return gulp.watch(watchList, gulp.series(`compile:sass:${theme.name}:watch`));
  }));
});

So it does appear to work in some use cases?

rossb89 avatar Jun 15 '22 07:06 rossb89

I notice you're also using the /**/* syntax, I wonder if that's all there is to it?

prurigro avatar Jun 16 '22 16:06 prurigro

It would be nice if gulp maintainers release newer version with just dependecies for chokidar push to compatible with modern versions of nodejs.

Today I've lost few hours while trying to identify why watch is not working. The solution is simple - override dependencies, what is avabile since NPM v8.3.0 + (2021-12-09), but I would not need it and would not lose my precious time for fixing that dummy thing :(

Here is the overrides section for package.json:

  "overrides": {
    "gulp": {
      "glob-watcher": "^5.0.5"
    },
    "glob-watcher": {
      "anymatch": "^3.1.3",
      "async-done": "^2.0.0",
      "chokidar": "^3.5.3"
    }
  },

xtracoder avatar May 25 '23 22:05 xtracoder

I usually use nvm. Here's an article explaining how it works, in Portuguese (my native language): https://fabiojanio.medium.com/nvm-gerencie-m%C3%BAltiplas-instala%C3%A7%C3%B5es-do-node-js-6fcd0f13aaf7 in English: https://www.freecodecamp.org/news/node-version-manager-nvm-install-guide/

jonathanafranio avatar Oct 03 '23 14:10 jonathanafranio