Because packages depend on other packages. A few dependencies in package.json expand into a deep tree of transitive dependencies, which results in thousands of files and a large folder on disk.
What Are node_modules and Why Do They Bloat Your React Project?
Why is node_modules so large?
The answer
More FAQs in What Are node_modules and Why Do They Bloat Your React Project?
It is the folder where npm installs every package your project depends on, plus all of their dependencies recursively. It is generated from package.json and the lockfile by running npm install.
No. node_modules is large and fully reproducible from package.json and the lockfile. Add it to .gitignore. Committing it bloats the repository and causes merge conflicts.
It records the exact versions of every installed package, including transitive dependencies, so that every install produces the same node_modules. It ensures consistency across machines and team members.
Still have questions?
Browse all our FAQs or reach out to our support team
Want to upskill yourself?
Your learning library
Small steps. Big possibilities.
Find your next course. Build something great.