Registry / devops / gitignore

gitignore

JSON →
library0.7.0jsnpmunverified

CLI tool and Node.js module to automatically fetch .gitignore templates for any project type from GitHub's official gitignore repository. Current stable version is 0.7.0. Release cadence is irregular; last update was in 2019. Key differentiator: provides both a global CLI command and a programmatic API, with support for NPX for one-off invocations. Compared to alternatives (e.g., gitignore.io), it directly pulls from GitHub's authoritative collection with no external API dependency.

npm install gitignore
INSTALL
IMPORT
SIG · GITIGNORE
G
gitignore
devopsjavascriptv0.7.0
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

getTypes
const { getTypes } = require('gitignore');
import { getTypes } from 'gitignore';
This package is CommonJS-only; ESM import will fail. Use require for now.
writeFile
const { writeFile } = require('gitignore');
import { writeFile } from 'gitignore';
Same as getTypes: CommonJS only. No default export; named exports require destructuring.
default import
const gitignore = require('gitignore');
import gitignore from 'gitignore';
If you import the whole module, it will be an object with getTypes and writeFile. ESM import will not work.

Programmatically fetch the Node.gitignore template and write it to a local file.

const { writeFile } = require('gitignore'); const fs = require('fs'); const fileStream = fs.createWriteStream('.gitignore'); writeFile({ type: 'node', file: fileStream }, (err) => { if (err) console.error(err); else console.log('Created .gitignore for Node'); });
Debug
Known issues
deprecatedPackage uses deprecated 'request' library which is no longer maintained.
fix
Switch to alternatives like 'node-fetch' or 'axios' as the package is not actively maintained.
affects: >=0.5.0
gotchaCLI command needs global install or npx; using globally installed version may conflict with module install.
fix
Use npx gitignore <type> to avoid global install conflicts.
affects: >=0.6.0
gotchaThe 'types' list is fetched live from GitHub; network issues can cause failure.
fix
Ensure network connectivity or cache the types list locally.
affects: >=0.1.0
gotchaThe module's getTypes and writeFile only work with callbacks; no promise support.
fix
Wrap callbacks with util.promisify for async/await usage.
affects: >=0.5.0
Errors
Common errors & fixes
Error: Cannot find module 'gitignore'
Global installation not performed or NPX not used.
fix
Run 'npm install -g gitignore' for global CLI or use 'npx gitignore <type>'.
TypeError: gitignore.getTypes is not a function
Using default import with ESM syntax which returns an empty object.
fix
Use CommonJS require: const { getTypes } = require('gitignore');
Error: listen EADDRINUSE :::80
Attempting to run gitignore with invalid argument that triggers unintended server.
fix
Use correct type argument: 'gitignore node' instead of 'gitignore --port'.
Upgrade
Version history
0.7.0latest on npm
Audit
Dependencies
requestrequiredHTTP requests to GitHub for fetching template types and content.
mkdirprequiredUsed for creating directories if needed during file writing.
Agent activity
2 hits · last 30 days
node
2
Resources
gitignore — npm install gitignore · libregistry