why it is necessary to ignore node_modules from git repo?
The other users who will use my code from repo ,don't they will need my node_modules folder ?
why it is necessary to ignore node_modules from git repo?
The other users who will use my code from repo ,don't they will need my node_modules folder ?
These modules are external dependencies of your application and you should have added them in your packages.json
accordingly.
You don't have to include the entire source of these packages because you can install them with a single command: npm install
, and for many other reasons (see jfriend00 comment).
So usually, when developping an app, we add node_modules
to .gitignore
to prevent dependencies from being versionned.
It is not necessary (you can always do what you want), but it is strongly recommanded to leave your repo clean and maintainable.
node_module is too big and you already have package.json that helps to to install all packages in node_module by npm install
/ yarn install
command.
keep small, clean and maintainable so add node_module in .gitignore file .
There is no need to version the whole node_modules, because you achieve the same goal using the package.json file, which is the description of the dependencies required by your application.
When other users check-in your versionned code, a simple npm install
is enough to gather those dependencies using the description provided in the package.json file.