Skip to content

docs(only-allow-pnpm): added option to enforce pnpm with package.json and .npmrc #692

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

karthikappiah
Copy link

@karthikappiah karthikappiah commented Jul 21, 2025

TLDR

I added a non-invasive update to a single page of the docs. Currently, the docs only tell you to add npx only-allow pnpm to the preinstall script inside package.json, the option—to set the .npmrc configuration variable engine-strict as true and specify PNPM as the enforced package manager in the package.json—is not in the docs, which is why I added this option to the docs and created a pull request.

How to Enforce PNPM as the Only Package Manager

For easier reference, here is one of many GitHub threads that describe the same issue:

As per the NPM docs, to prevent the use of an unspecified package manager, from Node v16.9.0 (backported to v14.19.0) onwards, you should:

  1. Create a file, if it doesn't already exist, named .npmrc at the root of your project.
  2. Set the following configuration variable in your .npmrc to true:
engine-strict=true
  1. Specify the following fields in your package.json:
{
  "devEngines": {
    "runtime": {
      "name": "node",
      "onFail": "error"
    },
    "packageManager": {
      "name": "pnpm",
      "version": "10.13.1",
      "onFail": "error"
    }
  },
  "engines": {
    "node": ">=18.18.0",
    "pnpm": ">=10.0.0"
  },
}
  • Now, when you run npm i or npm i -D, these commands return this error (before the preinstall script can run):
username@hostname nodejs-project % npm i -D package
npm error code EBADDEVENGINES
npm error EBADDEVENGINES The developer of this package has specified the following through devEngines
npm error EBADDEVENGINES Invalid engine "packageManager"
npm error EBADDEVENGINES Invalid name "pnpm" does not match "npm" for "packageManager"
npm error EBADDEVENGINES {
npm error EBADDEVENGINES   current: { name: 'npm', version: '10.9.2' },
npm error EBADDEVENGINES   required: { name: 'pnpm', onFail: 'error' }
npm error EBADDEVENGINES }
npm error A complete log of this run can be found in: /Users/username/.npm/_logs/2021-08-21T00_00_00_000Z-debug-0.log

Copy link

Review PR in StackBlitz Codeflow Run & review this pull request in StackBlitz Codeflow.

Copy link

vercel bot commented Jul 21, 2025

@karthikappiah is attempting to deploy a commit to the pnpm Team on Vercel.

A member of the Team first needs to authorize it.

@karthikappiah
Copy link
Author

karthikappiah commented Jul 21, 2025

I created a different pull request previously with the default branch name patch-4, so I renamed my branch more descriptively, hence another pull request.

We should consider a pull request template (like a form someone must fill out), similar to how the NextAuth documentation handles pull requests. I believe this will simplify merging pull requests.

@karthikappiah karthikappiah force-pushed the docs_only-allow-pnpm_engine-strict-true branch from 1bdc729 to 8b38ae9 Compare July 21, 2025 22:02
@karthikappiah karthikappiah changed the title docs: added option to only allow pnpm with engine-strict=true docs(only-allow-pnpm): added option to enforce pnpm with engine-strict=true Jul 21, 2025
@karthikappiah karthikappiah changed the title docs(only-allow-pnpm): added option to enforce pnpm with engine-strict=true docs(only-allow-pnpm): added option to enforce pnpm with engine-strict=true in .npmrc Jul 21, 2025
@karthikappiah karthikappiah changed the title docs(only-allow-pnpm): added option to enforce pnpm with engine-strict=true in .npmrc docs(only-allow-pnpm): added option to enforce pnpm with package.json and .npmrc Jul 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant