user606521
user606521

Reputation: 15454

How to turn off yarn@2 PnP?

I am using Yarn 2.0.0-rc.27 + workspaces + TypeScript and I want to turn PnP off and use node_modules again. I tried it with following setting in package.json:

"installConfig": {
  "pnp": false
},

However, Yarn uses PnP mode every time. Is there any option to turn it off?

Upvotes: 56

Views: 22858

Answers (2)

Runi
Runi

Reputation: 1366

I ran into a bunch of issues with Yarn 2 as well using the same stack. The solution is to create a .yarnrc.yml file with the following line:

nodeLinker: node-modules

This can also be done with following yarn command:

yarn config set nodeLinker node-modules

Upvotes: 135

Csaba K.
Csaba K.

Reputation: 166

Sometimes it is enough to run yarn unplug [problem package name] to get it working again with pnp mode.

For instance in case of next.js v12 pnp mode started to not work again (it worked with v10/v11) and the solution was to simply yarn unplug next -- it remembers that you did it by adding a new dependenciesMeta entry into the package.json file.

Upvotes: 2

Related Questions