{"id":18389,"library":"glob-fs-gitignore","title":"glob-fs-gitignore","description":"Middleware for glob-fs that automatically ignores files and directories specified in .gitignore patterns. Version 0.1.6, last updated in 2017. Built by Jon Schlinkert as part of the glob-fs ecosystem. It integrates seamlessly with glob-fs to provide gitignore-aware file globbing. The package is stable but minimally maintained. It differs from alternatives like ignore by being a middleware for glob-fs rather than a standalone library. Works with Node.js >=0.12.0.","status":"maintenance","version":"0.1.6","language":"javascript","source_language":"en","source_url":"https://github.com/jonschlinkert/glob-fs-gitignore","tags":["javascript","fs","gitignore","glob","glob-fs","ignore","middleware","parse","pattern"],"install":[{"cmd":"npm install glob-fs-gitignore","lang":"bash","label":"npm"},{"cmd":"yarn add glob-fs-gitignore","lang":"bash","label":"yarn"},{"cmd":"pnpm add glob-fs-gitignore","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Peer dependency; this middleware requires glob-fs to function.","package":"glob-fs","optional":false}],"imports":[{"note":"The default export is a function. In CommonJS, use require('glob-fs-gitignore') directly.","wrong":"const { gitignore } = require('glob-fs-gitignore')","symbol":"default","correct":"import gitignore from 'glob-fs-gitignore'"},{"note":"CommonJS require returns the function directly; no .default needed.","wrong":"const gitignore = require('glob-fs-gitignore').default","symbol":"default (CommonJS)","correct":"const gitignore = require('glob-fs-gitignore')"},{"note":"The module has no type definitions; use @types/glob-fs-gitignore or declare module.","wrong":"import * as gitignore from 'glob-fs-gitignore'","symbol":"TypeScript usage","correct":"import gitignore from 'glob-fs-gitignore'"}],"quickstart":{"code":"const glob = require('glob-fs')({ dotfiles: true });\nconst gitignore = require('glob-fs-gitignore');\n\nglob.use(gitignore())\n  .readdir('**/*', function(err, files) {\n    if (err) throw err;\n    console.log(files);\n  });","lang":"javascript","description":"Demonstrates using glob-fs-gitignore middleware to ignore .gitignore patterns while globbing."},"warnings":[{"fix":"Use glob-fs without disabling defaults; it includes gitignore handling automatically.","message":"Note: glob-fs-gitignore is built-in to glob-fs as default middleware. Only use this package if you have disabled the default middleware stack in glob-fs.","severity":"deprecated","affected_versions":">=0.1.0"},{"fix":"Ensure to invoke gitignore() as a function: glob.use(gitignore())","message":"The middleware must be called as a function (gitignore()) when passed to .use(). Omitting parentheses yields an error or unexpected behavior.","severity":"gotcha","affected_versions":">=0.1.0"}],"env_vars":null,"last_verified":"2026-04-25T00:00:00.000Z","next_check":"2026-07-24T00:00:00.000Z","problems":[{"fix":"Use const gitignore = require('glob-fs-gitignore');","cause":"Importing incorrectly in CommonJS, e.g., const { gitignore } = require('glob-fs-gitignore') when the module exports a function directly.","error":"TypeError: gitignore is not a function"},{"fix":"Run npm install glob-fs-gitignore glob-fs","cause":"The package is not installed or is missing from node_modules. Also ensure glob-fs is installed as a peer dependency.","error":"Cannot find module 'glob-fs-gitignore'"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}