{"id":27197485,"url":"https://github.com/dereknongeneric/project516","last_synced_at":"2026-01-20T23:02:47.945Z","repository":{"id":103618063,"uuid":"346882681","full_name":"DerekNonGeneric/project516","owner":"DerekNonGeneric","description":"See nodejs/modules#516","archived":false,"fork":false,"pushed_at":"2024-02-27T23:58:55.000Z","size":3,"stargazers_count":0,"open_issues_count":2,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2024-05-01T16:25:49.141Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":null,"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/DerekNonGeneric.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}},"created_at":"2021-03-12T00:35:19.000Z","updated_at":"2021-03-12T03:52:52.000Z","dependencies_parsed_at":null,"dependency_job_id":"fef3afc3-6f55-459e-ae25-07e7ac176204","html_url":"https://github.com/DerekNonGeneric/project516","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DerekNonGeneric%2Fproject516","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DerekNonGeneric%2Fproject516/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DerekNonGeneric%2Fproject516/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DerekNonGeneric%2Fproject516/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/DerekNonGeneric","download_url":"https://codeload.github.com/DerekNonGeneric/project516/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248106698,"owners_count":21048780,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":[],"created_at":"2025-04-09T20:28:52.739Z","updated_at":"2026-01-20T23:02:47.841Z","avatar_url":"https://github.com/DerekNonGeneric.png","language":null,"funding_links":[],"categories":[],"sub_categories":[],"readme":"# project516\n\nTest fixture for `Module.resolvePackageRoot`. See [nodejs/modules#516](https://github.com/nodejs/modules/issues/516).\n\n## Definitions\n\n\u003cdl\u003e\n  \u003cdt\u003e\u003cstrong\u003e\u003ccode\u003eModule.resolvePackageRoot\u003c/code\u003e\u003c/strong\u003e\u003c/dt\u003e\n  \u003cdd\u003eAllows users to determine the \u003cem\u003epackage root\u003c/em\u003e of a package specifier\u003c/dd\u003e\n\u003c/dl\u003e\n\n\u003cdl\u003e\n  \u003cdt\u003epackage root\u003c/dt\u003e\n  \u003cdd\u003ethe directory containing the \u003ccode\u003epackage.json\u003c/code\u003e that served as the module's entrypoint\u003c/dd\u003e\n\u003c/dl\u003e\n\n## Syntax\n\n```mjs\nModule.resolvePackageRoot(specifier);\nModule.resolvePackageRoot(specifier, base);\n```\n\nIf `base` is omitted, the equivalent of [`process.cwd()`](https://nodejs.org/api/process.html#process_process_cwd) will be used.\n\n## Examples\n\nOmitting `base` and getting the `package.json` of a package specifier. Hypothetical minimal example.\n\n```mjs\nimport module from 'module';\nimport path from 'path';\n\nconst tapePkgRoot = module.resolvePackageRoot('tape');\nconst tapePjsonPath = path.resolve(tapePkgRoot, 'package.json');\nconst tapePjsonData = await import(tapePjsonPath); // :p\n\nconsole.log(tapePjsonData);\n```\n\nProviding `base` and getting the `package.json` of a package (bare) specifier. Example that _could_ work today.\n\n```mjs\nimport { promises as fs } from 'fs';\nimport module from 'module';\nimport path from 'path';\n\nconst lodashPkgRoot = module.resolvePackageRoot('lodash', import.meta.url);\nconst lodashPjsonPath = path.resolve(lodashPkgRoot, 'package.json');\nconst lodashPjsonData = JSON.parse(await fs.readFile(lodashPjsonPath, 'utf-8')); // :/\n\nconsole.log(lodashPjsonData);\n```\n\nOmitting `base` and getting the `package.json` of a package (bare) specifier in only a few lines.\n\n```mjs\nimport { resolvePackageRoot } from 'module';\nimport { join } from 'path';\n\nconst jestPjsonData = await import(\n  join(resolvePackageRoot('jest'), 'package.json'),\n  { assert { type: 'json' } }); // !\n\nconsole.log(jestPjsonData);\n```\n\n## Codebase layout\n\n```tree\n/app/\n├── /node_modules/\n│   └── /cjs-logger/\n│   │   └── package.json\n│   └── /esm-logger/\n│   │   └── package.json\n│   └── /logger/\n│       ├── /cjs/\n│       │   ├── logger.js\n│       │   └── package.json\n│       ├── /esm/\n│       │   ├── logger.js\n│       │   └── package.json\n│       └── package.json\n└── package.json\n```\n\n| /app/ | |\n| --- | --- |\n| `/app/node_modules/logger/package.json` | package boundary at `/app/node_modules/logger` |\n| `/app/node_modules/logger/esm/package.json` | package boundary at `/app/node_modules/logger/esm` , in theory can contain `\"exports\"` |\n| `/app/node_modules/logger/cjs/package.json` | package boundary at `/app/node_modules/logger/cjs` , in theory can contain `\"exports\"` |\n\n## Further reading\n\n- [📦 `realize-package-specifier`](https://www.npmjs.com/package/realize-package-specifier)\n- [📦 `npm-package-arg`](https://www.npmjs.com/package/npm-package-arg)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdereknongeneric%2Fproject516","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdereknongeneric%2Fproject516","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdereknongeneric%2Fproject516/lists"}