Back to Pnpm Io

Only allow pnpm

versioned_docs_archived/version-3.x/only-allow-pnpm.md

latest547 B
Original Source

When you use pnpm on a project, you don't want others to accidentally run npm install or yarn. To prevent devs from using other package managers, add the following preinstall script to your package.json:

json
{
  "scripts": {
    "preinstall": "node -e '!process.env.npm_config_user_agent.startsWith(\"pnpm/\")&&!console.log(\"Use `npx pnpm install` to install dependencies in this repository\\n\")&&process.exit(1)'"
  }
}

Next time, when someone runs npm install or yarn install, they'll get an error message in the console.