---
name: pnpm11-pnpmfile-requirement
description: pnpm 11.0.9+ requires a .pnpmfile.mjs file in the project root even when no hooks are needed — install fails without it
type: concept
---

# pnpm 11 — `.pnpmfile.mjs` Required

## The Problem

After upgrading to pnpm 11.0.9+, `pnpm install` fails with:

```
 ERR_PNPM_NO_PNPMFILE  .pnpmfile.mjs not found
```

Or in some cases the install silently produces unexpected behavior because pnpm 11 changed the default hooks expectation.

## The Fix

Create an empty `.pnpmfile.mjs` in the project root:

```js
// .pnpmfile.mjs
export default {}
```

This satisfies pnpm's requirement without adding any actual hook behavior.

## When You Need Actual Hooks

If you need to patch package manifests (the common use case for `.pnpmfile.mjs`):

```js
// .pnpmfile.mjs
export default {
  hooks: {
    readPackage(pkg, context) {
      // Example: force a specific version of a transitive dependency
      if (pkg.dependencies?.['some-package']) {
        pkg.dependencies['some-package'] = '^2.0.0'
      }
      return pkg
    }
  }
}
```

## Version Context

- pnpm 10.x: `.pnpmfile.cjs` (CommonJS format)
- pnpm 11.x: `.pnpmfile.mjs` (ESM format, required)

If migrating from pnpm 10 to 11, rename and convert `.pnpmfile.cjs` to `.pnpmfile.mjs` and update the export syntax from `module.exports = { hooks: ... }` to `export default { hooks: ... }`.

## .gitignore

`.pnpmfile.mjs` should be committed — it's a project-level config, not a generated file.

**Source:** daily/2026-05-13.md | 2026-05-13
