Check that the correct package manager is being used with your project.
To configure the correct package manager, you can use the packageManager
property in your package.json
file or you can specify it in the cli arguments.
ℹ️ This package requires Node >= 18
. If you use an older Node version, the cli will exit and print a warning.
npm i check-package-manager -D
ℹ️ You can use npx check-package-manager [options]
in your preinstall
script if you don't want to add it as a dependency.
check-package-manager [options] [packageManager]
ℹ️ Depending on the package manager being used, the preinstall
script may get invoked after dependencies are installed.
packageManager
(optional) - <package manager name>[@<version>]
--info
- Print info messages
--debug
- Print debug messages
When using corepack:
{
"name": "YOUR-PACKAGE-NAME",
"version": "1.0.0",
"packageManager": "pnpm@7.19.0",
"scripts": {
"preinstall": "npx check-package-manager"
}
}
Specify the package manager name and version yourself:
{
"name": "YOUR-PACKAGE-NAME",
"version": "1.0.0",
"scripts": {
"preinstall": "npx check-package-manager npm@9.2.0"
}
}
Specify only the package manager name:
{
"name": "YOUR-PACKAGE-NAME",
"version": "1.0.0",
"scripts": {
"preinstall": "npx check-package-manager yarn"
}
}
fnm use
corepack enable
pnpm install
pnpm build