What is the node_modules folder in a 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.
Verify This Answer
Cross-check this information using these trusted sources:
More FAQs in What Are node_modules and Why Do They Bloat Your React Project?
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.
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
