# Node modules folder in forked github repo?

**URL:** <https://discourse.nodered.org/t/node-modules-folder-in-forked-github-repo/79911>\
**Category:** Developing Nodes\
**Created:** [18 July 2023 17:25 UTC](https://discourse.nodered.org/t/node-modules-folder-in-forked-github-repo/79911 "2023-07-18T17:25:05Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![Joe-AB1DO](https://avatars.discourse-cdn.com/v4/letter/j/f19dbf/32.png) [@Joe-AB1DO](https://discourse.nodered.org/u/Joe-AB1DO)\
**Post date:** [18 July 2023 17:25 UTC](https://discourse.nodered.org/t/node-modules-folder-in-forked-github-repo/79911/1 "2023-07-18T17:25:05Z")

</div>

About 9 months ago or so I successfully forked a node-red github repo and have been updating the .html and .js files ever since using vscode, regularly committing the changes to my forked repo. One thing I did notice is that in my forked repo a node\_modules folder shows, which does not show in the original repo. I have not added any additonal node.js libraries. In fact, looking at the contents of that node\_modules folder, I don't recognize any of the files.

The reason I ask is that the original maintainer has given me collaborator status and as such I now have push-access. However I do not want to push the node\_modules folder in my forked repo to the original repo, which does not have that folder. Should I be worried about this at all? Is there anything I can try/test before actually pushing my fork to the original repo?

This is my first coding project using vscode and using github and it has been quite the learning experience. So I apologize in advance for my ignorance or if this question has been asked and answered before. Just point me in the right direction and I will take it from there.

Thanks,  
Joe

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [18 July 2023 17:39 UTC](https://discourse.nodered.org/t/node-modules-folder-in-forked-github-repo/79911/2 "2023-07-18T17:39:38Z")

</div>

You should have a .gitignore file and it should contain various things like `node_modules` and others.

Here is a reasonable example: [https://github.com/microsoft/vscode-samples/blob/master/.gitignore](https://github.com/microsoft/vscode-samples/blob/master/.gitignore)

And here is a write-up: [Gitignore Explained: What is Gitignore and How to Add it to Your Repo](https://www.freecodecamp.org/news/gitignore-what-is-it-and-how-to-add-to-repo/)

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [18 July 2023 17:43 UTC](https://discourse.nodered.org/t/node-modules-folder-in-forked-github-repo/79911/3 "2023-07-18T17:43:24Z")

</div>

As for why it exists: it contains necessary dependencies that are installed when `npm install` is executed. Typically, it contains all of the dependencies and developer dependencies mentioned in the adjacent `package.json` and many of them can/will be dependents of the dependencies.

In short, never commit `node_modules`

---

<div class="post-metadata">

**Author:** ![Joe-AB1DO](https://avatars.discourse-cdn.com/v4/letter/j/f19dbf/32.png) [@Joe-AB1DO](https://discourse.nodered.org/u/Joe-AB1DO)\
**Post date:** [18 July 2023 18:10 UTC](https://discourse.nodered.org/t/node-modules-folder-in-forked-github-repo/79911/4 "2023-07-18T18:10:36Z")

</div>

Steve,

thanks, that helps. So just to be clear, should I just delete the node\_modules folder in my forked repo?

Joe

---

<div class="post-metadata">

**Author:** ![Joe-AB1DO](https://avatars.discourse-cdn.com/v4/letter/j/f19dbf/32.png) [@Joe-AB1DO](https://discourse.nodered.org/u/Joe-AB1DO)\
**Post date:** [18 July 2023 19:08 UTC](https://discourse.nodered.org/t/node-modules-folder-in-forked-github-repo/79911/5 "2023-07-18T19:08:34Z")

</div>

OK got it. Added .gitignore file, committed to online repo and deleted node\_modules folder from online repo.

Thanks again for helping out on this,  
Joe

---

<div class="post-metadata">

**Author:** ![Joe-AB1DO](https://avatars.discourse-cdn.com/v4/letter/j/f19dbf/32.png) [@Joe-AB1DO](https://discourse.nodered.org/u/Joe-AB1DO)\
**Post date:** [23 July 2023 16:56 UTC](https://discourse.nodered.org/t/node-modules-folder-in-forked-github-repo/79911/6 "2023-07-23T16:56:15Z")

</div>

So now that I am familiar with .gitignore and node\_modules folder (thank you @Steve-Mcl) I have 2 follow-on questions:

- Should I include package-lock.json in .gitignore? I'm guessing yes, but just thought I'd check.

- If so, can I then safely remove package-lock.json from my github repo, like I did with the node\_modules folder? Again, I'm guessing yes as from everything I have read on package-lock.json it gets created when doing an npm install.

Joe

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [23 July 2023 17:51 UTC](https://discourse.nodered.org/t/node-modules-folder-in-forked-github-repo/79911/7 "2023-07-23T17:51:46Z")

</div>

There are 2 schools of thought with regards to the package lock.

Personally, I don't but I'm some cases it is beneficial e.g. for teams of developers to get the exact same dependency versions installed.

In the case of a simple node red node package that a lone developer works on, I'd say don't bother publishing the package lock (exclude it via git ignore)

---

<div class="post-metadata">

**Author:** ![Joe-AB1DO](https://avatars.discourse-cdn.com/v4/letter/j/f19dbf/32.png) [@Joe-AB1DO](https://discourse.nodered.org/u/Joe-AB1DO)\
**Post date:** [24 July 2023 15:44 UTC](https://discourse.nodered.org/t/node-modules-folder-in-forked-github-repo/79911/8 "2023-07-24T15:44:26Z")

</div>

Understood and good point on the development team aspect.

Thanks again,  
Joe

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [22 September 2023 15:45 UTC](https://discourse.nodered.org/t/node-modules-folder-in-forked-github-repo/79911/9 "2023-09-22T15:45:22Z")

</div>

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.
