I'm working with a PNPM monorepo setup, and everything was working fine when I was using pnpm.yaml, but after switching to pnpm-workspace.yaml, I’m encountering the following error:
ERROR packages field is not an array
For help, run: pnpm help run
Here’s my current directory structure:
root-directory/
├── packages/
│ └── main/
│ ├── index.js
│ └── package.json
├── package.json
└── pnpm-workspace.yaml
Root package.json:
{
"name": "@levelup/root",
"version": "1.0.0",
"scripts": {
"main:start": "pnpm -F @levelup/main run start",
"test": "echo \"Error: no test specified\" && exit 1"
},
"packageManager": "pnpm@10.5.1"
}
pnpm-workspace.yaml:
packages:
- "packages/**"
The error occurs because the packages
field in your pnpm-workspace.yaml
file is not formatted correctly. In YAML, lists should be properly indented and use a hyphen (-
) for each item.
packages:
- "packages/**"
Make sure there are no extra spaces or incorrect indentation.
packages:
- "packages/**"
pnpm-workspace.yaml
and ensure the packages field is written correctly.pnpm install
again.