Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why I have too many packages inside my node_modules?

Tags:

npm

I am new, and when i first created my app based on the documentation using npm create-react-app i found it there were a lot of package included inside folder node_module when i code and i only use react and react DOM and etc from the basic.

node_modules
 acorn
 timer
 ansi
 and many more

I wonder if anyone can help my how to understand each use inside the node_module or where can i find the documentation for each use?

or how can i just reduce to what i want to use only to decrease the app size?

like image 712
Michael Vinci Avatar asked Oct 17 '22 10:10

Michael Vinci


1 Answers

The answers are 2:

  1. because you're using an automated scaffolding tool, which essentially does everything for you, and, you have just to code, it is supposed to locally deploy all the packages it needs to work (for example webpack is needed to bundle your code, babel to transpile it, ...
  2. under node_modules you will find all the packages of the whole app. That's means you will find both your dependencies and the dependencies of your dependencies (this rule has some exceptions and you can find them in the npm documentation.

example:

// your code depends on A

var dependency = require('A');

// but then, inside your A dependency you can also find something similar to:

var b = require('B');

how can i just reduce to what i want to use only to decrease the app size?

You basically can't do it. They are all needed.

like image 76
Hitmands Avatar answered Oct 21 '22 00:10

Hitmands