graceful-fs VS chokidar

Compare graceful-fs vs chokidar and see what are their differences.

graceful-fs

fs with incremental backoff on EMFILE (by isaacs)

chokidar

Minimal and efficient cross-platform file watching library (by paulmillr)
Our great sponsors
  • SurveyJS - Open-Source JSON Form Builder to Create Dynamic Forms Right in Your App
  • InfluxDB - Power Real-Time Data Analytics at Scale
  • WorkOS - The modern identity platform for B2B SaaS
graceful-fs chokidar
3 23
1,264 10,542
- -
3.0 5.0
10 months ago 29 days ago
JavaScript JavaScript
ISC License MIT License
The number of mentions indicates the total number of mentions that we've tracked plus the number of user suggested alternatives.
Stars - the number of stars that a project has on GitHub. Growth - month over month growth in stars.
Activity is a relative number indicating how actively a project is being developed. Recent commits have higher weight than older ones.
For example, an activity of 9.0 indicates that a project is amongst the top 10% of the most actively developed projects that we are tracking.

graceful-fs

Posts with mentions or reviews of graceful-fs. We have used some of these posts to build our list of alternatives and similar projects. The last one was on 2022-11-19.
  • My fist codestory. A day in my life, as a coder :)
    2 projects | dev.to | 19 Nov 2022
    async (config?: { /** * Overwrite the default ignored behavior */ customIgnored?: string[]; }) => { const projectRoot = getProjectRoot(); if (!projectRoot) return; // NB: fix to globally alter real fs in order to fix EMFile error that happens in TSMorph (see https://github.com/isaacs/node-graceful-fs) gracefulFs.gracefulify(realFs); console.log("Searching..."); const tsFunctions = await db.get("TsFunction"); const projectWatcherTsFunctions = tsFunctions.filter( (x) => x.explicitTypeName === "ProjectWatcher" ); const projectWatchers = projectWatcherTsFunctions .map((x) => x.name) .map((name) => sdk[name as keyof typeof sdk] as ProjectWatcher | undefined) .filter(notEmpty); log(`${projectWatchers.length} watchers gonna watch ${projectRoot}`, { type: "important", }); const startupWaitMs = 1000; setTimeout(() => { log( `There they are! \n\n${projectWatchers .map((projectWatcher) => { return `👁 👁 ${projectWatcher.name} ✅`; }) .join("\n")}`, { type: "success", } ); }, startupWaitMs); const startTimeAt = Date.now(); watch(projectRoot, { ignoreInitial: true, ignored: config?.customIgnored || [ "**/node_modules/**", "**/.next/**", "**/.expo/**", "**/build/**", "**/db/**", "**/.git/**", "**/.turbo/**", "**/generated/**", ], // alwaysStat: true, // not sure why I would need this, seems inefficient if I don't need it, I can simply run fs.stat }).on("all", (eventName, path, stats) => { if (Date.now() < startTimeAt + startupWaitMs) return; const relevantWatchers = projectWatchers.filter((watcher) => watcher.filter(eventName, path) ); oneByOne(relevantWatchers, async (projectWatcher) => { await projectWatcher(eventName, path); }); }); };
  • My theory on why so many people are bad at coding.
    8 projects | /r/ExperiencedDevs | 12 Aug 2022
    What's probably got your shorts in a knot is the contents of the node_modules directory. That directory is a cache for mode.js modules so the tutorial can function standalone without having to install anything else. Treat it as you would object code. I pulled a half-dozen of those modules at random and went to their repositories. Every one of them had unit tests: block-stream, graceful-fs, lowercase-keys, minimist, pify and safe-buffer. Nobody sane ships unit tests with their executables.
  • I'm a noob, I've hit a wall and I need a bit of handholding re: creating node.js app
    5 projects | /r/learnjavascript | 25 Apr 2022
    graceful-fs https://www.npmjs.com/package/graceful-fs

chokidar

Posts with mentions or reviews of chokidar. We have used some of these posts to build our list of alternatives and similar projects. The last one was on 2024-04-18.
  • The best testing setup for frontends, with Playwright and NextJS
    5 projects | dev.to | 18 Apr 2024
    For this, we'll use chokidar - more specifically the chokidar-cli package. chokidar is probably the most useful file watching library for the nodejs ecosystem and it will serve us well.
  • Why Does 'Is-Number' Package Have 59M Weekly Downloads?
    2 projects | news.ycombinator.com | 4 Mar 2024
    tailwindcss -> chokidar -> braces -> fill-range -> to-regex-range -> is-number

    is-number was first published 9 years ago, when these kind of micro-packages were in vogue. braces was added as a dependency to chokidar over 6 years ago [1]. And if it ain't broke, don't fix it. I don't think the average JS dev today is going out and pulling in these deps.

    [1] https://github.com/paulmillr/chokidar/commit/cbdf25563cfff7f...

  • How nodemon works?
    1 project | /r/node | 19 Aug 2023
    The watching magic is really in the https://www.npmjs.com/package/chokidar library
  • Dart 3.1 and a retrospective on functional style programming in Dart
    7 projects | news.ycombinator.com | 17 Aug 2023
    > It’s typical to listen to this stream of events and use chained if-else statements to determine an action based on the type of the events that occur.

    You'd think something like directory watching would have a clear set of events that would make nice objects with consistent meanings, but in my experience file watching gets crazy complicated, and can have all sorts of edge cases.

    Just take a looked here for all the various edge cases that crop up: https://github.com/paulmillr/chokidar/issues

    Then you have linux, windows, macos, and maybe you want to abstract over some underlying implementation like chokidar vs fb/watchman vs webpack/watchpack. Every new OS release could also cause things to change.

    So usually its going to be a bunch of if-else statements hacked together to get around edge cases, and have to be revisited later on.

    Any attempt to abstract this into objects, just obfuscates things. And OO forces you to name things, when in fact they might be un-nameable. `FileSystemModifyEventExceptWhenXAndYAndSometimesZ`.

    The behavior might rely on a series of events together, so the object hierarchy must be re-worked.

    OO has this rosy idea that we just have to come up with the perfect hierarchy, but things change in unexpected ways, and everything must have a descriptive noun.

  • Is there anyway to auto reload the browser page when using express?
    2 projects | /r/learnjavascript | 13 Jun 2023
    Next, you can use a library like chokidar to listen for changes in your source directory. Create a ws server, and whenever a file changes, send a message.
  • How does nodemon works under the hood?
    4 projects | /r/node | 14 Mar 2023
    As another has mentioned, nodemon uses chokidar under the hood for the actual file watching part.
  • Turbowatch – Extremely fast alternative to Nodemon
    7 projects | /r/javascript | 13 Mar 2023
    At the end of the day, ironically, Nodemon does not even implement file watching functionality. It is a thin wrapper around chokidar (see source code), and the way it is being used is neither efficient (CPU and your battery usage) or performant. So it is not a false argument, just perhaps not the most appealing.
  • dĂșvida provavelmente idiota
    1 project | /r/brdev | 23 Jan 2023
  • How is React's Hot Module Reloading implemented (at a medium-high level of detail)?
    3 projects | /r/reactjs | 15 Nov 2022
    for file watching, it might use something similar to https://www.npmjs.com/package/chokidar
  • Setup TailwindCSS, postcss and esbuild on Rails 7
    12 projects | dev.to | 12 Oct 2022
    First, we need to install chokidar to enable watching and automatically refreshing our files.

What are some alternatives?

When comparing graceful-fs and chokidar you can also consider the following projects:

fs-extra - Node.js: extra methods for the fs object like copy(), remove(), mkdirs()

Filehound - Flexible and fluent interface for searching the file system

fs-jetpack - Better file system API for Node.js

Nodemon.io - Monitor for any changes in your node.js application and automatically restart the server - perfect for development

globby - User-friendly glob matching

proper-lockfile - An inter-process and inter-machine lockfile utility that works on a local or network file system.

Watch-fn

fs-write-stream-atomic - Like `fs.createWriteStream(...)`, but atomic.

filenamify - Convert a string to a valid safe filename

mkdirp - Recursively mkdir, like `mkdir -p`, but in node.js