-
Notifications
You must be signed in to change notification settings - Fork 309
ERR_PACKAGE_PATH_NOT_EXPORTED when other playwright versions are installed globally (pnpm) #340
Description
Description
When installing @playwright/cli globally via pnpm alongside other packages that depend on playwright-core (e.g. @playwright/test, @vercel/next-browser), the CLI fails immediately:
```
Error [ERR_PACKAGE_PATH_NOT_EXPORTED]: Package subpath './lib/tools/cli-client/program'
is not defined by "exports" in .../pnpm/node_modules/playwright-core/package.json
at exportsNotFound (node:internal/modules/esm/resolve:313:10)
at packageExportsResolve (node:internal/modules/esm/resolve:661:9)
at resolveExports (node:internal/modules/cjs/loader:679:36)
...
```
Root Cause
@playwright/cli depends on playwright-core@1.60.0-alpha-* transitively (via playwright), but does not declare it as a direct dependency. pnpm deduplicates playwright-core to the highest compatible version already in the global store — in my case 1.58.2 from @playwright/test@1.59.1. That version does not export ./lib/tools/cli-client/program, causing the crash.
This does not happen with npm because npm installs each package with its own isolated node_modules tree.
Environment
- Node: v24.13.0
- pnpm: 10.32.1
@playwright/cli: 0.1.4- Conflicting globals:
@playwright/test@1.59.1,@vercel/next-browser@0.1.8
Workaround
Manually symlink the correct playwright-core version into @playwright/cli's node_modules:
```bash
ln -s
~/.local/share/pnpm/global/5/.pnpm/playwright-core@1.60.0-alpha-1775061447000/node_modules/playwright-core
~/.local/share/pnpm/global/5/.pnpm/@playwright+cli@0.1.4/node_modules/playwright-core
```
(Paths vary by OS — adjust accordingly.)
Suggested Fix
Add playwright-core as a direct dependency in package.json so pnpm cannot hoist a mismatched version:
```json
"dependencies": {
"minimist": "^1.2.5",
"playwright": "1.60.0-alpha-1775061447000",
"playwright-core": "1.60.0-alpha-1775061447000"
}
```