The size of the node_modules folder is not a problem. This is a privilege

My thoughts on the node_modules folder size debate

I used to be very angrynode_modulesFolder size. How can a JavaScript application reach a size of 100 or 200MB without me adding any code? I just rannpx create-react-app todolistI downloaded 218,7MBthing! (I checked now, this is a real number).

Whenever you consider the size of node_modules, please consider the millions of man-hours invested by our programmers.

This is all open source software. You can check and learn the software. Donated by programmers and companies around the world. This is a global effort, and someone can easily benefit from it. Happens to benpm, First is the tool, then the company.

We all agree to publish the code on their servers, and then people build things on top of their heads, and build other things on top of their heads, until we have a quick start (such as create-react-app or Vue CLI). Can be used to get a lot of power for free.

Is 200MB too much in the era of terabyte fast storage?

Keep in mind that the vast majority of this size is for testing, documentation, not so much. Moreover, most of the remaining code is only used in the development environment. It is not that you will provide a 200MB application to the client, I think it is well known.

I take create-react-app as an example. What's in that 200MB?

First, create-react-app contains

  • Compiler (Babel)
  • Bundler (Webpack)
  • Code compressor
  • Short velvet (ESLint)
  • Style Pipeline Tool (SCSS)
  • Development server with real-time reload
  • Runner (joke)

If you want to write a Mac or iPhone application, you must installXcode, The IDE provided by Apple.Xcode(Wait for it.) Almost 14GB. That is 70 times the size of node_modules. Admittedly, we are comparing two different things, but node_modules contains everything you need to start writing code. You can pair it with VS Code which is 200MB in size, or Sublime Text which is 30MB-it doesn't matter, even someone who doesn't have strict requirements (although without iOS, you can't create iOS/macOS appsXcode).

If your hard drive is full of modules,pnpmIt is an optimal embedded solution, it concentrates the modules in one place, and all your applications use these modules instead of making your own local version. Online coding tools (e.g.glitchE.g.

I have read that many people want to know if our application relies on too much code written by others, how they will audit the security or other issues in the code base.

This is a choice, right? You are not forced to use modules. You can create your own version of the tool, which does not require all these modules, but then you will have to maintain the code, test it, manage the new version if it needs to be updated, and so

I have the opportunity to work with other languages and ecosystems, and the vitality and opportunities of npm should have been lucky, but I had to build my own small library for everything because I found something distributed by the developers of the third part It has not existed or been abandoned for several years, and has not kept pace with other languages.

Maybe we can have a logo to download only the production code without downloading all the documentation, testing, what else? But this is just an idea I am thinking of now, not sure how to implement it.

Anyway: Long live,node_modules!

Download mine for freeJavaScript beginner's manual

More js tutorials: