DEV Community

Lem Dulfo
Lem Dulfo

Posted on

Solved: npm or yarn install node_modules is too big

TLDR: It might be your node_modules hoisting limit configuration. Run yarn config get nmHoistingLimits

Background Context:

A colleague's local environment was generating a different licenses.txt file than what our CI system was generating, so his pull requests kept failing in CI.

licenses.txt is important when releasing a React Native app to the public, like Apple App Store or Google Play Store, especially when including MIT-licensed packages. Otherwise, your company might be held liable for improper attribution.

meme saying no to driver's license, yes to MIT license

Process of elimination, we compared our environments:

  • same: license-checker npm package
  • same: yarn.lock
  • same: nodenv, node, and yarn versions
  • same: .yarnrc
  • different: yarn install speed
  • different: string searching node_modules for one arbitrary library @babel/code-frame library yielded 100 results for me, and 400+ for him

It didn't initially make sense that the same package.json would behave differently, when our node and yarn were the same versions, and even our .yarnrc

Not knowing how to proceed, I described my problem to Chat GPT and it gave me this command to try:

yarn config list
Enter fullscreen mode Exit fullscreen mode

We ran this and found out that my config had this, and his did not:

nmHoistingLimits: 'workspaces'
Enter fullscreen mode Exit fullscreen mode

Hope this helps!

Top comments (0)