Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

jimmy.puckett's avatar

Should you exclude "node_modules" in .gitignore?

I am new to the nom/bower stuff, and I am not exactly sure of the purpose of this folder, so I am not sure if it is supposed to be part of your repository or not. Do you guys exclude it or let it get checked in?

Thanks.

0 likes
6 replies
chrisgeary92's avatar
Level 13

Yes you should include it within the .gitignore :) All of the packages pulled into their have their own .git repos, so no point including them in your own.

HRcc's avatar

Definitely exclude it :) It's often a huge folder.

1 like
jimmy.puckett's avatar

Is there anything like the composer.lock file that does need to be included?

JeffreyWay's avatar

I think that's it. For things like this, add it to your gitignore_global file, rather than your project's .gitignore.

1 like
nWidart's avatar

I'd put it the projects .gitignore file, just like the vendor/ folder. Since it isn't a OS specific folder (like .DS_STORE etc.) it shouldn't be in the global .gitignore file in my opinion.

1 like
chrisgeary92's avatar

If you're building a project that only you work on, then sure put it in the global ignore file. But what happens if your building a project shared with others? You cannot guarantee they have /node_modules in their global ignore file as well?

1 like

Please or to participate in this conversation.