{"id":15641257,"url":"https://github.com/egoist/detect-package-manager","last_synced_at":"2025-04-13T06:28:33.604Z","repository":{"id":23864098,"uuid":"100042991","full_name":"egoist/detect-package-manager","owner":"egoist","description":"Detect which package manager you're using (yarn or pnpm or npm)","archived":false,"fork":false,"pushed_at":"2024-08-19T14:02:20.000Z","size":124,"stargazers_count":88,"open_issues_count":13,"forks_count":8,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-04-04T05:43:55.549Z","etag":null,"topics":["npm","package-manager","pnpm","yarn"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","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/egoist.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},"funding":{"github":"egoist"}},"created_at":"2017-08-11T14:57:30.000Z","updated_at":"2025-03-22T16:25:59.000Z","dependencies_parsed_at":"2024-10-03T11:42:08.481Z","dependency_job_id":"0944664b-1ef3-4daf-af76-bb74bec74812","html_url":"https://github.com/egoist/detect-package-manager","commit_stats":{"total_commits":20,"total_committers":5,"mean_commits":4.0,"dds":0.4,"last_synced_commit":"de2318f4b57ff1db8d8fba90948a834dd88de0bb"},"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/egoist%2Fdetect-package-manager","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/egoist%2Fdetect-package-manager/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/egoist%2Fdetect-package-manager/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/egoist%2Fdetect-package-manager/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/egoist","download_url":"https://codeload.github.com/egoist/detect-package-manager/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248674100,"owners_count":21143644,"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":["npm","package-manager","pnpm","yarn"],"created_at":"2024-10-03T11:42:02.055Z","updated_at":"2025-04-13T06:28:33.578Z","avatar_url":"https://github.com/egoist.png","language":"TypeScript","funding_links":["https://github.com/sponsors/egoist"],"categories":[],"sub_categories":[],"readme":"# detect-package-manager\n\n[![NPM version](https://img.shields.io/npm/v/detect-package-manager.svg?style=flat)](https://npmjs.com/package/detect-package-manager) [![NPM downloads](https://img.shields.io/npm/dm/detect-package-manager.svg?style=flat)](https://npmjs.com/package/detect-package-manager) [![CircleCI](https://circleci.com/gh/egoist/detect-package-manager/tree/master.svg?style=shield)](https://circleci.com/gh/egoist/detect-package-manager/tree/master) [![donate](https://img.shields.io/badge/$-donate-ff69b4.svg?maxAge=2592000\u0026style=flat)](https://github.com/egoist/donate)\n\n## How does this work?\n\n1. When there's `yarn.lock`, `package-lock.json`, `pnpm-lock.yaml`, or `bun.lockb` in current working directory, it will skip other operations and directly resolve `yarn`, `npm`, `pnpm`, or `bun`.\n2. When there's no lockfile found, it checks if `yarn`, `pnpm`, or `bun` command exists. If so, it resolves `yarn`, `pnpm`, or `bun` otherwise `npm`.\n3. Results are cached.\n\n## Install\n\n```bash\nyarn add detect-package-manager\n```\n\n## Usage\n\n```js\nconst { detect } = require(\"detect-package-manager\");\n\ndetect().then((pm) =\u003e {\n  console.log(pm);\n  //=\u003e 'yarn', 'npm', or 'pnpm', 'bun'\n});\n```\n\n## API\n\n### detect([opts])\n\n- Arguments:\n  - `opts.cwd`: `string` Optional, defaults to `.`, the directory to look up `yarn.lock`, `package-lock.json`, or `pnpm-lock.yaml`.\n  - `opts.includeGlobalBun`: `boolean` Optional, defaults to `false`, whether to check if `bun` exists in PATH.\n- Returns: `Promise\u003cPM\u003e`\n\nIt returns a Promise resolving the name of package manager, could be `npm`, `yarn`, or `pnpm`, `bun`.\n\n### getNpmVersion([pm])\n\n- Arguments:\n  - `pm`: `string` Optional, defaults to `npm`, could be `npm`, `yarn`, or `pnpm`, `bun`\n- Returns: `Promise\u003cstring\u003e`\n\nIt returns a Promise resolving the version of npm or the package manager you specified.\n\n### clearCache()\n\n- Returns: `void`\n\nClear cache.\n\n## Contributing\n\n1. Fork it!\n2. Create your feature branch: `git checkout -b my-new-feature`\n3. Commit your changes: `git commit -am 'Add some feature'`\n4. Push to the branch: `git push origin my-new-feature`\n5. Submit a pull request :D\n\n## Author\n\n**detect-package-manager** © [EGOIST](https://github.com/egoist), Released under the [MIT](./LICENSE) License.\u003cbr\u003e\nAuthored and maintained by EGOIST with help from contributors ([list](https://github.com/egoist/detect-package-manager/contributors)).\n\n\u003e [github.com/egoist](https://github.com/egoist) · GitHub [@EGOIST](https://github.com/egoist) · Twitter [@\\_egoistlily](https://twitter.com/_egoistlily)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fegoist%2Fdetect-package-manager","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fegoist%2Fdetect-package-manager","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fegoist%2Fdetect-package-manager/lists"}