{"id":13483218,"url":"https://github.com/sindresorhus/package-json","last_synced_at":"2025-05-15T02:07:20.760Z","repository":{"id":17904261,"uuid":"20861133","full_name":"sindresorhus/package-json","owner":"sindresorhus","description":"Get metadata of a package from the npm registry","archived":false,"fork":false,"pushed_at":"2024-07-14T11:05:58.000Z","size":77,"stargazers_count":240,"open_issues_count":3,"forks_count":63,"subscribers_count":8,"default_branch":"main","last_synced_at":"2025-04-10T11:45:14.752Z","etag":null,"topics":[],"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/sindresorhus.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":".github/security.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":"sindresorhus","open_collective":"sindresorhus","buy_me_a_coffee":"sindresorhus","custom":"https://sindresorhus.com/donate"}},"created_at":"2014-06-15T17:35:30.000Z","updated_at":"2025-03-01T07:39:11.000Z","dependencies_parsed_at":"2024-01-13T10:13:19.087Z","dependency_job_id":"ae224f7f-4fd8-43f6-8a76-fc426d95a971","html_url":"https://github.com/sindresorhus/package-json","commit_stats":{"total_commits":108,"total_committers":20,"mean_commits":5.4,"dds":0.2777777777777778,"last_synced_commit":"a9182587204e589eea9879ea0a84a4b875002082"},"previous_names":[],"tags_count":35,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sindresorhus%2Fpackage-json","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sindresorhus%2Fpackage-json/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sindresorhus%2Fpackage-json/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sindresorhus%2Fpackage-json/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sindresorhus","download_url":"https://codeload.github.com/sindresorhus/package-json/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248317709,"owners_count":21083528,"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":"2024-07-31T17:01:09.144Z","updated_at":"2025-04-11T09:33:22.421Z","avatar_url":"https://github.com/sindresorhus.png","language":"JavaScript","funding_links":["https://github.com/sponsors/sindresorhus","https://opencollective.com/sindresorhus","https://buymeacoffee.com/sindresorhus","https://sindresorhus.com/donate"],"categories":["Packages","JavaScript"],"sub_categories":["Registry"],"readme":"# package-json\n\n\u003e Get metadata of a package from the npm registry\n\n## Install\n\n```sh\nnpm install package-json\n```\n\n## Usage\n\n```js\nimport packageJson from 'package-json';\n\nconsole.log(await packageJson('ava'));\n//=\u003e {name: 'ava', …}\n\n// Also works with scoped packages\nconsole.log(await packageJson('@sindresorhus/df'));\n```\n\n## API\n\n### packageJson(packageName, options?)\n\n#### packageName\n\nType: `string`\n\nName of the package.\n\n#### options\n\nType: `object`\n\n##### version\n\nType: `string`\\\nDefault: `latest`\n\nPackage version such as `1.0.0` or a [dist tag](https://docs.npmjs.com/cli/dist-tag) such as `latest`.\n\nThe version can also be in any format supported by the [semver](https://github.com/npm/node-semver) module. For example:\n\n- `1` - Get the latest `1.x.x`\n- `1.2` - Get the latest `1.2.x`\n- `^1.2.3` - Get the latest `1.x.x` but at least `1.2.3`\n- `~1.2.3` - Get the latest `1.2.x` but at least `1.2.3`\n\n##### fullMetadata\n\nType: `boolean`\\\nDefault: `false`\n\nBy default, only an abbreviated metadata object is returned for performance reasons. [Read more](https://github.com/npm/registry/blob/master/docs/responses/package-metadata.md), or see the [type definitions](index.d.ts).\n\n##### allVersions\n\nType: `boolean`\\\nDefault: `false`\n\nReturn the [main entry](https://registry.npmjs.org/ava) containing all versions.\n\n##### registryUrl\n\nType: `string`\\\nDefault: Auto-detected\n\nThe registry URL is by default inferred from the npm defaults and `.npmrc`. This is beneficial as `package-json` and any project using it will work just like npm. This option is **only** intended for internal tools. You should **not** use this option in reusable packages. Prefer just using `.npmrc` whenever possible.\n\n##### omitDeprecated\n\nType: `boolean`\\\nDefault: `true`\n\nWhether or not to omit deprecated versions of a package.\n\nIf set, versions marked as deprecated on the registry are omitted from results. Providing a dist tag or a specific version will still return that version, even if it's deprecated. If no version can be found once deprecated versions are omitted, a [`VersionNotFoundError`](#versionnotfounderror) is thrown.\n\n### PackageNotFoundError\n\nThe error thrown when the given package name cannot be found.\n\n### VersionNotFoundError\n\nThe error thrown when the given package version cannot be found.\n\n## Authentication\n\nBoth public and private registries are supported, for both scoped and unscoped packages, as long as the registry uses either bearer tokens or basic authentication.\n\n## Proxies\n\nProxy support is not implemented in this package. If necessary, use a global agent that modifies [`fetch`](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API), which this package uses internally.\n\nSupport for this may come to [Node.js in the future](https://github.com/nodejs/undici/issues/1650).\n\n## Related\n\n- [package-json-cli](https://github.com/sindresorhus/package-json-cli) - CLI for this module\n- [latest-version](https://github.com/sindresorhus/latest-version) - Get the latest version of an npm package\n- [pkg-versions](https://github.com/sindresorhus/pkg-versions) - Get the version numbers of a package from the npm registry\n- [npm-keyword](https://github.com/sindresorhus/npm-keyword) - Get a list of npm packages with a certain keyword\n- [npm-user](https://github.com/sindresorhus/npm-user) - Get user info of an npm user\n- [npm-email](https://github.com/sindresorhus/npm-email) - Get the email of an npm user\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsindresorhus%2Fpackage-json","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsindresorhus%2Fpackage-json","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsindresorhus%2Fpackage-json/lists"}