{"id":10948,"library":"git-node-fs","title":"Node.js Adapter for js-git File System Access","description":"git-node-fs is a Node.js adapter designed to provide file system access for the deprecated `js-git` library. It enables `js-git` to interact with Git repositories directly on the local filesystem. The package's latest version, 1.0.0, was published over 10 years ago, indicating it is no longer actively maintained. Its core dependency, `js-git`, also appears to be unmaintained, making `git-node-fs` unsuitable for new projects or environments requiring modern Git features or security updates. Developers seeking current Git integration in Node.js should explore actively maintained alternatives such as `isomorphic-git` or `simple-git` which offer broader platform support (including browsers) and modern JavaScript features like Promises and ESM. The package provides a CommonJS interface for mixing file system capabilities into a `js-git` repository object.","status":"abandoned","version":"1.0.0","language":"javascript","source_language":"en","source_url":"https://github.com/creationix/git-node-fs","tags":["javascript","git","js-git"],"install":[{"cmd":"npm install git-node-fs","lang":"bash","label":"npm"},{"cmd":"yarn add git-node-fs","lang":"bash","label":"yarn"},{"cmd":"pnpm add git-node-fs","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Core dependency providing the Git object model, which this package adapts for Node.js filesystem access. It is also unmaintained.","package":"js-git","optional":false}],"imports":[{"note":"This package is CommonJS-only and does not support ES Modules.","wrong":"import fsAdapter from 'git-node-fs';","symbol":"git-node-fs","correct":"const fsAdapter = require('git-node-fs');"},{"note":"The mixin is applied by directly requiring the path and invoking it, typical for older Node.js patterns. It is not exported as a named or default ES module.","wrong":"import { fsDbMixin } from 'git-node-fs/mixins/fs-db';","symbol":"fs-db mixin","correct":"require('js-git/mixins/fs-db')(repo, fsAdapter);"},{"note":"While 'require(\"fs\")' works, it's best practice in modern Node.js to use the 'node:' prefix for built-in modules to avoid ambiguity with npm packages named 'fs'.","wrong":"const fs = require('fs');","symbol":"fs (Node.js built-in)","correct":"const fs = require('node:fs');"}],"quickstart":{"code":"const path = require('node:path');\nconst fsAdapter = require('git-node-fs');\n\n// Initialize a repository object (this is a js-git concept)\nconst repo = {};\n\n// Point the repository to a .git directory\n// For a non-bare repository, it would be the .git folder within the worktree.\n// For a bare repository, it would be the bare repo directory itself.\nrepo.rootPath = path.join(__dirname, '.git');\n\n// Mix in the filesystem database adapter from git-node-fs into the repo object\n// This allows js-git operations to interact with the local filesystem.\nrequire('js-git/mixins/fs-db')(repo, fsAdapter);\n\nconsole.log('Repository configured for git-node-fs:');\nconsole.log(repo);\n\n// At this point, `repo` can be used with other js-git mixins to perform\n// Git operations like reading commits, trees, blobs, etc.\n// Example (requires more js-git setup):\n// const { readCommit } = require('js-git/mixins/walkers')(repo);\n// readCommit('HEAD', (err, commit) => {\n//   if (err) { console.error('Error reading commit:', err); return; }\n//   console.log('HEAD commit:', commit.short); // Assuming a 'short' property exists or similar.\n// });\n","lang":"javascript","description":"This quickstart demonstrates how to set up a `js-git` repository object with `git-node-fs` to enable local filesystem interaction for Git operations."},"warnings":[{"fix":"Ensure your project is configured for CommonJS (`package.json` `\"type\": \"commonjs\"`) or use `require()` syntax within an ES module context by employing dynamic import or a transpilation step.","message":"The package is CommonJS-only and does not support ES Modules. Attempting to `import` it will result in a runtime error.","severity":"breaking","affected_versions":"1.0.0"},{"fix":"Avoid using `git-node-fs` for new projects. Migrate existing projects to actively maintained Git libraries for Node.js such as `isomorphic-git` or `simple-git`.","message":"This package, and its core dependency `js-git`, are largely unmaintained and have not seen updates in over a decade. They are not compatible with modern Git features, Node.js versions, or best practices, and may contain unpatched security vulnerabilities.","severity":"breaking","affected_versions":"1.0.0"},{"fix":"If using TypeScript, you will need to create custom declaration files (`.d.ts`) or use `@ts-ignore` to suppress type errors.","message":"No TypeScript type definitions (`.d.ts` files) are provided or available for `git-node-fs` or `js-git`. Usage in TypeScript projects will require manual type declarations or casting to `any`.","severity":"gotcha","affected_versions":"1.0.0"},{"fix":"Always explicitly import Node.js built-in modules using the `node:` prefix (e.g., `require('node:fs')`) to prevent accidentally importing an unrelated npm package.","message":"The `fs` argument in `require('js-git/mixins/fs-db')(repo, fs)` refers to Node.js's built-in `fs` module, not an npm package with the same name. There are npm packages named `fs` (e.g., `fs@0.0.1-security`, `node-fs`) that are security placeholders or deprecated modules.","severity":"gotcha","affected_versions":"1.0.0"}],"env_vars":null,"last_verified":"2026-04-19T00:00:00.000Z","next_check":"2026-07-18T00:00:00.000Z","problems":[{"fix":"If in an ES module, use dynamic `import()` or switch to a CommonJS file (e.g., rename to `.cjs` or set `\"type\": \"commonjs\"` in `package.json`). This package does not provide ESM exports.","cause":"Attempting to use `require()` in an ES module context, or using `import` for a CommonJS-only package.","error":"TypeError: require is not a function"},{"fix":"Ensure `js-git` is installed: `npm install js-git`. Verify the module path in your `require()` statement is correct.","cause":"The `js-git` package, or its specific mixin, is not installed or incorrectly resolved.","error":"Error: Cannot find module 'js-git/mixins/fs-db'"}],"ecosystem":"npm"}