1

I have an error when trying to push my React app onto Github. First I created the repository in Github. Then, I added the remote repository using git remote add origin <repo name>. Then I added and commit the files. Lastly I tried git push -u origin main. I got the following error:

remote: error: File node_modules/.cache/default-development/0.pack is 153.50 MB; this exceeds GitHub's file size limit of 100.00 MB
remote: error: File node_modules/.cache/default-development/4.pack is 131.01 MB; this exceeds GitHub's file size limit of 100.00 MB
remote: error: File node_modules/.cache/default-development/2.pack is 131.43 MB; this exceeds GitHub's file size limit of 100.00 MB
remote: error: File node_modules/.cache/default-production/0.pack is 131.55 MB; this exceeds GitHub's file size limit of 100.00 MB
remote: error: File node_modules/.cache/default-development/9.pack is 131.12 MB; this exceeds GitHub's file size limit of 100.00 MB

I do not understand how it would exceed the limit as I have created two other React apps with more code in the past and uploaded them the same way to Github. The only difference I can think of is that this project uses Tailwind Css and Firebase. How can I reduce the size of node_modules/.cache/default-development/9.pack or even find what the file is?

KaiTheGuy
  • 93
  • 1
  • 8
  • 2
    You should not commit `node_modules` into Git. You only want to commit the package lockfile. https://stackoverflow.com/q/18128863/2954547. Unfortunately these large files are now embedded in Git history and will need to be removed with a tool like BFG Repo Cleaner. https://stackoverflow.com/questions/tagged/bfg-repo-cleaner. – shadowtalker Jan 12 '22 at 14:52

3 Answers3

3

No need to push node_modules in git delete node_module then push it and then Just make a file .gitignore in the same directory where package.json and write

/node_modules

then try to push it and then you can run npm install

Jay Patel
  • 1,098
  • 7
  • 22
  • 2
    `node_modules` has already been committed so `.gitignore` is not enough. – phd Jan 12 '22 at 15:01
  • I know that he needs to delete node_module then push it and then he needs to add .gitignore – Jay Patel Jan 12 '22 at 15:02
  • I edited the answer please remove your downvote and if you like it please upvote it means a lot – Jay Patel Jan 12 '22 at 15:10
  • "*…delete node_module…*" Not enough just to delete and commit — `node_module` stays in previous commit(s). One needs to remove `node_module` from all previous commit(s) and that a bit harder then just "delete and push". – phd Jan 12 '22 at 15:18
  • yeah but node_module is in last 10 commits then it's better to not delete the last commits just delete them from now onwards – Jay Patel Jan 12 '22 at 15:20
  • 2
    In that case large files are still in the previous commits and GitHub would not allow to push. "*…better to not delete the last commits…*" I never say anything about deleting commits, only about deleting large files from the previous commits. – phd Jan 12 '22 at 15:23
  • Let us [continue this discussion in chat](https://chat.stackoverflow.com/rooms/241003/discussion-between-phd-and-jay-patel). – phd Jan 12 '22 at 15:33
2

In my experience, it is crucial to include this line in .gitignore

# eslint cache
.eslintcache

in addition to /node_modules (as mentioned by others). This prevents the *.pack cache files from being pushed which are very very large (at least in my case). This solved my problem. I hope it will be of help to others.

Claudio M
  • 65
  • 6
0

Nothing to worry , just go to your Project folder --> right click anywhere and check if show hidden files checked --> now you see a .git folder --> just delete that -> and thats it your problem is solved

create repo again with git init ........