iTranslated by AI

The content below is an AI-generated translation. This is an experimental feature, and may contain errors. View original article
😇

node_modules is Deeper Than a Black Hole

に公開

Recently, node_modules has become deeper than a black hole, and it's painful.
In Node.js, for example, the system searches inside node_modules directories while gradually moving up the directory tree to find the module name specified in an import statement or a require function.

As a result, the directory hierarchy tends to become infinitely deep. Like this:

  • node_modules
    • lib_a
      • node_modules
        • lib_c
    • lib_c

Because of this, the size of node_modules—including development packages—is no joke. It's common for it to take up several GBs of space.
I hate having large disk capacity required by dependency libraries, and I want to keep the dependency tree as flat as possible.

I think things would change significantly if different versions of the same package were not allowed to exist in the dependency tree. In fact, I feel like we could manage somehow if all recursive dependencies were added to the package.json of the root package...

Discussion