Got similar problem today with yarn 4.9.2 and nextjs 16. It turned out the problem is with pnp nodelinker, change to node-modules by adding nodeLinker: node-modules to .yarnrc.yml then the problem gone.
Have tried several times with yarn pnp but always go back to node-modules then.