【问题标题】:Cannot push my React project to Github, file size exceeds file size of 100.00MB无法将我的 React 项目推送到 Github,文件大小超过 100.00MB
【发布时间】:2022-01-12 23:03:46
【问题描述】:

我在尝试将我的 React 应用程序推送到 Github 时出错。首先,我在 Github 中创建了存储库。然后,我使用git remote add origin <repo name> 添加了远程存储库。然后我添加并提交文件。最后我尝试了git push -u origin main。我收到以下错误:

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

我不明白它是如何超过限制的,因为我过去创建了另外两个具有更多代码的 React 应用程序,并以相同的方式将它们上传到 Github。我能想到的唯一区别是这个项目使用了 Tailwind Css 和 Firebase。如何减小node_modules/.cache/default-development/9.pack 的大小,甚至找到文件是什么?

【问题讨论】:

标签: reactjs git github


【解决方案1】:

无需在 git 中推送 node_modules 删除 node_module 然后推送它,然后 只需在package.json 所在的同一目录中创建一个文件.gitignore 并写入

/node_modules

然后尝试推动它 然后你可以运行npm install

【讨论】:

  • node_modules 已经提交,所以 .gitignore 还不够。
  • 我知道他需要删除node_module然后push它然后他需要添加.gitignore
  • 我编辑了答案,请删除您的反对意见,如果您喜欢,请点赞,这意味着很多
  • "...delete node_module..." 仅仅删除和提交是不够的——node_module 保留在之前的提交中。需要从所有以前的提交中删除node_module,这比“删除并推送”更难。
  • 在这种情况下,大文件仍在之前的提交中,GitHub 不允许推送。 “……最好不要删除最后的提交……”我从不说删除提交,只说从以前的提交中删除大文件。
猜你喜欢
  • 2021-12-22
  • 1970-01-01
  • 1970-01-01
  • 2021-09-06
  • 2018-01-02
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多