skip to Main Content

I have a react project with a root directory and a client directory. Earlier I had worked from just the root directory as usual but I decided to create a new client directory for the front-end code I’d been writing while I kept the back-end code in the root directory. After making this separation, I have not been able to push my code to GitHub. I get an error stating that the node_modules in the client folder contains files that are too large. I have tried to create a new repository and push there instead but it is still the same result, so the problem seems to come from my codebase. I have added node_modules to the gitignore folder in the root directory so that it does not get pushed to the repository but still to no avail. I have even tried git LFS for large file storage but I still get the same errors. I have already finished my project for the most part and I have been pushing code to my repository ever since. This problem just came out of nowhere. This is the message I get in my terminal

It gets to this point and halts here for a long time:

git push --set-upstream origin master
Enumerating objects: 44178, done.
Counting objects: 100% (44178/44178), done.
Delta compression using up to 4 threads
Compressing objects: 100% (31530/31530), done.
Writing objects: 100% (44175/44175), 386.79 MiB | 15.49 MiB/s, done.
Total 44175 (delta 11605), reused 43933 (delta 11488), pack-reused 0

Then eventually, this is the full message:

$ git push --set-upstream origin master
Enumerating objects: 44178, done.
Counting objects: 100% (44178/44178), done.
Delta compression using up to 4 threads
Compressing objects: 100% (31530/31530), done.
Writing objects: 100% (44175/44175), 386.79 MiB | 15.49 MiB/s, done.
Total 44175 (delta 11605), reused 43933 (delta 11488), pack-reused 0
remote: Resolving deltas: 100% (11605/11605), completed with 1 local object.
remote: error: Trace: 404752adfd4ea24fa4470b58cfe8deab2314f93248e63256a319fb89bcdc4128
remote: error: See https://gh.io/lfs for more information.
remote: error: File client/node_modules/.cache/default-development/1.pack is 133.46 MB; this exceeds GitHub's file size limit of 100.00 MB
remote: error: File client/node_modules/.cache/default-development/10.pack is 409.51 MB; this exceeds GitHub's file size limit of 100.00 MB
remote: error: File client/node_modules/.cache/default-development/13.pack is 415.16 MB; this exceeds GitHub's file size limit of 100.00 MB
remote: error: File client/node_modules/.cache/default-development/24.pack is 132.23 MB; this exceeds GitHub's file size limit of 100.00 MB
remote: error: File client/node_modules/.cache/default-development/27.pack is 406.89 MB; this exceeds GitHub's file size limit of 100.00 MB
remote: error: GH001: Large files detected. You may want to try Git Large File Storage - https://git-lfs.github.com.
To https://github.com/ojieprincewill/baroque.git
 ! [remote rejected]   master -> master (pre-receive hook declined)
error: failed to push some refs to 'https://github.com/ojieprincewill/baroque.git'

2

Answers


    1. Create .gitignore file in the root folder of your app.
    2. Insert this line: /node_modules.
    3. Commit your changes and push them to git.

    *If you already made a commit before creating the .gitignore file, you should close your terminal and commit them again.

    EDIT

    package.json file contains all of your dependencies. When you need to download your project on another device, all you need to do is run npm install – that will generate node_modules automatically.

    Login or Signup to reply.
  1. /node_modules folder should not be in the Git. To exclude this folder from being tracked by Git, you need to create a .gitignore file in the root directory of your project and add the following line in that file:

    /node_modules
    

    Then commit your changes again and push to your repository.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search