Yarn plug ‘n play, my experience and why i won’t use it

Srecko Kostic
2 min readOct 24, 2021

Feature of Yarn berry is plug ‘n play, which allows us to use npm ecosystem without having massive node_modules folder locally, which often has large size. That sounded great untill I tried to use it and it turned out not to be so great.

Photo by Francisco Gonzalez on Unsplash

Yarn pnp is fast, node_modules are reliable

Cloning repository or initializing project and having it run 10s after sounds good to me. Initializing CRA project takes a few minutes to set up directory, this is IO operation which is slow and the more size node_modules have, more time it takes.

If developers have to clone massive project or delete node_modules to fix some weird bugs due to it, it’ll take a few minutes to install everything from package.json. Nightmare.

On the other hand, node_modules is old system and it just works, everyone got used to it and we just tackle new problems as they occur. I mean, deleting folder is easy, sometimes.

Only price is time.

Yarn pnp is fast untill you start having errors

  • Typescript requires special treatment, even worse, in general to use it, depending on your editor, there’s a whole section explaining how to use pnp with those https://yarnpkg.com/getting-started/editor-sdks.
  • React has types when library is installed, but with pnp I had to add types/react and types/react-dom.
  • There is problem with husky pre-commit hooks. I’ve banged my head because it didn’t work for 2 hours only to find out that removing pnp fixes the problem.

Conclusion

It has one benefit, speed, however problems it causes makes me feel more and more unwilling to use it another time. Every attempt it was set up in one of my experimental environments new problem happened and it was most likely because of pnp.

I am disapointed it was released as stable version, because it isn’t.

Because it’s released as stable version, makes me roll my eyes when hearing yarn pnp, because there just will be issues and each of them requires sloppy workaround.

--

--

Srecko Kostic

I create content from my perspective on topics I learn. Some information may be incorrect, but I hope some find my content useful.