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
},
But yarn uses PnP mode every time. Is there any option to turn it off?
In this install mode (the default starting from Yarn 2.0), Yarn generates a single .pnp.cjs file instead of the usual node_modules folder containing copies of various packages.
Note: yarn remove will always update your package.json and yarn.lock. This ensures that different developers on the same project get the same set of dependencies. It is not possible to disable this behavior. Note: yarn remove <package> --<flag> uses the same flag s as yarn install command.
In case you find something that does not work, you should consult the Yarn's Troubleshooting section for some tips, then open an issue if things are still problematic. and finally put node_modules behind us once and for all.
Yarn Plug'n'Play provides semantic errors (explaining you the exact reason why a package isn't reachable from another) and a sensible JS API to solve various shortcomings with require.resolve. These are features that import maps wouldn't solve by themselves.
I ran into a bunch of issues with Yarn 2 as well using same stack. Solution is to create a .yarnrc.yml
file with the following line:
nodeLinker: node-modules
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With