https://github.com/webdeveric/check-package-manager
Check that you're using the correct package manager
https://github.com/webdeveric/check-package-manager
Last synced: 8 days ago
JSON representation
Check that you're using the correct package manager
- Host: GitHub
- URL: https://github.com/webdeveric/check-package-manager
- Owner: webdeveric
- License: mit
- Created: 2022-12-25T20:39:37.000Z (over 2 years ago)
- Default Branch: master
- Last Pushed: 2024-09-07T20:12:02.000Z (8 months ago)
- Last Synced: 2025-04-27T05:38:57.336Z (15 days ago)
- Language: TypeScript
- Homepage: https://www.npmjs.com/package/check-package-manager
- Size: 898 KB
- Stars: 3
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
- Funding: .github/FUNDING.yml
- License: LICENSE
- Codeowners: .github/CODEOWNERS
Awesome Lists containing this project
README
# check-package-manager
[](https://github.com/webdeveric/check-package-manager/actions/workflows/node.js.yml)
Check that the correct package manager is being used with your project.
To configure the correct package manager, you can use the [`packageManager` property](https://nodejs.org/api/packages.html#packagemanager) in your `package.json` file or you can specify it in the cli arguments.
:information_source: This package requires **Node >= `18`**. If you use an older Node version, the cli will exit and print a warning.
## Install
```shell
npm i check-package-manager -D
```:information_source: You can use `npx check-package-manager [options]` in your `preinstall` script if you don't want to add it as a dependency.
## Usage
```sh
check-package-manager [options] [packageManager]
```:information_source: Depending on the package manager being used, the `preinstall` script may get invoked after dependencies are installed.
### Arguments
`packageManager` (optional) - `[@]`
### Options
`--info` - Print info messages
`--debug` - Print debug messages
## Examples
When using [corepack](https://nodejs.org/api/corepack.html):
```json
{
"name": "YOUR-PACKAGE-NAME",
"version": "1.0.0",
"packageManager": "[email protected]",
"scripts": {
"preinstall": "npx check-package-manager"
}
}
```Specify the package manager name and version yourself:
```json
{
"name": "YOUR-PACKAGE-NAME",
"version": "1.0.0",
"scripts": {
"preinstall": "npx check-package-manager [email protected]"
}
}
```Specify only the package manager name:
```json
{
"name": "YOUR-PACKAGE-NAME",
"version": "1.0.0",
"scripts": {
"preinstall": "npx check-package-manager yarn"
}
}
```## Local development
```
fnm use
corepack enable
pnpm install
pnpm build
```