{"id":15011826,"url":"https://github.com/dependents/node-filing-cabinet","last_synced_at":"2026-05-05T07:02:33.725Z","repository":{"id":1092766,"uuid":"39693814","full_name":"dependents/node-filing-cabinet","owner":"dependents","description":"Get the file location associated with a dependency/partial's path","archived":false,"fork":false,"pushed_at":"2026-05-04T14:22:21.000Z","size":931,"stargazers_count":87,"open_issues_count":11,"forks_count":47,"subscribers_count":2,"default_branch":"main","last_synced_at":"2026-05-04T15:13:51.478Z","etag":null,"topics":["amd","ast","commonjs","es6","javascript","less","lookup","modules","partial","requirejs","resolver","sass","scss","stylus","webpack"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dependents.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2015-07-25T16:27:05.000Z","updated_at":"2026-05-04T13:48:06.000Z","dependencies_parsed_at":"2024-04-24T05:48:15.212Z","dependency_job_id":"49a5d099-479d-4b00-be0b-c22383441de2","html_url":"https://github.com/dependents/node-filing-cabinet","commit_stats":{"total_commits":213,"total_committers":27,"mean_commits":7.888888888888889,"dds":0.5070422535211268,"last_synced_commit":"aad468d6460c4c9e03eaa67277b333c515a86406"},"previous_names":["mrjoelkemp/node-filing-cabinet"],"tags_count":83,"template":false,"template_full_name":null,"purl":"pkg:github/dependents/node-filing-cabinet","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dependents%2Fnode-filing-cabinet","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dependents%2Fnode-filing-cabinet/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dependents%2Fnode-filing-cabinet/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dependents%2Fnode-filing-cabinet/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dependents","download_url":"https://codeload.github.com/dependents/node-filing-cabinet/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dependents%2Fnode-filing-cabinet/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32639059,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-04T10:08:07.713Z","status":"online","status_checked_at":"2026-05-05T02:00:06.033Z","response_time":54,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["amd","ast","commonjs","es6","javascript","less","lookup","modules","partial","requirejs","resolver","sass","scss","stylus","webpack"],"created_at":"2024-09-24T19:41:46.092Z","updated_at":"2026-05-05T07:02:33.713Z","avatar_url":"https://github.com/dependents.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# filing-cabinet\n\n[![CI](https://img.shields.io/github/actions/workflow/status/dependents/node-filing-cabinet/ci.yml?branch=main\u0026label=CI\u0026logo=github)](https://github.com/dependents/node-filing-cabinet/actions/workflows/ci.yml?query=branch%3Amain)\n[![npm version](https://img.shields.io/npm/v/filing-cabinet?logo=npm\u0026logoColor=fff)](https://www.npmjs.com/package/filing-cabinet)\n[![npm downloads](https://img.shields.io/npm/dm/filing-cabinet)](https://www.npmjs.com/package/filing-cabinet)\n\n\u003e Get the file associated with a dependency/partial's path\n\n```sh\nnpm install filing-cabinet\n```\n\n## Usage\n\n```js\nconst cabinet = require('filing-cabinet');\n\nconst result = cabinet({\n  partial: 'somePartialPath',\n  directory: 'path/to/all/files',\n  filename: 'path/to/parent/file',\n  ast: {}, // an optional AST representation of `filename`\n  // Only for JavaScript files\n  config: 'path/to/requirejs/config',\n  webpackConfig: 'path/to/webpack/config',\n  // Node modules entry resolution:\n  // - As an object: choose which package.json field to use as entry instead of \"main\"\n  nodeModulesConfig: {\n    entry: 'module'\n  },\n  // - Or as a function: fully custom package.json transformer (resolve's packageFilter)\n  //   nodeModulesConfig: (pkg) =\u003e {\n  //     // Example: prefer \"module\" and fallback to \"main\"\n  //     pkg.main = pkg.module ?? pkg.main;\n  //     return pkg;\n  //   },\n  tsConfig: 'path/to/tsconfig.json', // or an object\n  tsConfigPath: 'path/to/tsconfig.json'\n});\n\nconsole.log(result); // /absolute/path/to/somePartialPath\n```\n\n* `partial`: the dependency path\n  * This could be in any of the registered languages\n* `directory`: the path to all files\n* `filename`: the path to the file containing the `partial`\n* `ast`: (optional) the parsed AST for `filename`.\n  * Useful optimization for avoiding a parse of filename\n* `config`: (optional) requirejs config for resolving aliased JavaScript modules\n* `webpackConfig`: (optional) Webpack config for resolving aliased JavaScript modules. If exporting multiple configurations, the first configuration is used.\n* `nodeModulesConfig`: (optional) configuration to choose the entry file when resolving packages from `node_modules`.\n  * You can pass an object like `{ entry: 'module' }` — in this case the `entry` field replaces `main` in the target package's `package.json` (for example, to select the ESM entry via the `module` field).\n  * Or you can pass a function — a custom `packageFilter` from the [`resolve`](https://github.com/browserify/resolve#resolveid-opts-cb) package. The function receives the `package.json` object (`pkg`), may mutate it (e.g., set `pkg.main`), and must return the object. This gives you full control over how the entry file is selected.\n* `tsConfig`: (optional) path to a TypeScript configuration. Could also be an object representing a pre-parsed TypeScript config.\n* `tsConfigPath`: (optional) A (virtual) path to TypeScript config file when `tsConfig` option is given as an object, not a string. Needed to calculate [Path Mapping](https://www.typescriptlang.org/docs/handbook/module-resolution.html#path-mapping). If not given when `tsConfig` is an object, **Path Mapping** is ignored. This is not need when `tsConfig` is given as string (path to the tsconfig file).\n* `noTypeDefinitions`: (optional) For TypeScript files, whether to prefer `*.js` over `*.d.ts`.\n\n## Registered languages\n\nBy default, filing-cabinet provides support for the following languages:\n\n* JavaScript: CommonJS, AMD, ES6\n* TypeScript\n* CSS Preprocessors: Sass (`.scss` and `.sass`), Stylus (`.styl`), and Less (`.less`)\n* Svelte\n* Vue\n\nYou can register resolvers for new languages via `cabinet.register(extension, resolver)`.\n\n* `extension`: the extension of the file that should use the custom resolver (ex: '.py', '.php')\n* `resolver`: a function that accepts the following (ordered) arguments that were given to cabinet:\n  * `partial`\n  * `filename`\n  * `directory`\n  * `config`\n\nFor examples of resolver implementations, take a look at the default language resolvers:\n\n* [sass-lookup](https://github.com/dependents/node-sass-lookup)\n* [stylus-lookup](https://github.com/dependents/node-stylus-lookup)\n* [amdLookup](https://github.com/dependents/node-module-lookup-amd)\n\nIf a given extension does not have a registered resolver, cabinet will use\na generic file resolver which is basically `require('path').join` with a bit of extension defaulting logic.\n\n## CLI\n\nRequires a global install with `npm install -g filing-cabinet`\n\n```sh\nfiling-cabinet [options] \u003cdependencyPath\u003e\n```\n\nSee `filing-cabinet --help` for details on the options.\n\n## License\n\n[MIT](LICENSE)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdependents%2Fnode-filing-cabinet","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdependents%2Fnode-filing-cabinet","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdependents%2Fnode-filing-cabinet/lists"}