reactjs 无法将代码推送到GitHub,节点模块太大

ff29svar  于 12个月前  发布在  React
关注(0)|答案(2)|浏览(129)

我有一个react项目,有一个根目录和一个客户端目录。之前我像往常一样只在根目录下工作,但是我决定为我编写的前端代码创建一个新的客户端目录,而我将后端代码保留在根目录下。在进行了这种分离之后,我无法将代码推送到GitHub。我收到一个错误,指出node_客户端文件夹中的模块包含太大的文件。我尝试创建一个新的存储库并推送到那里,但结果仍然是一样的,所以问题似乎来自我的代码库。我已经添加了node_我甚至尝试过用git LFS来存储大文件,但还是得到了同样的错误。我已经完成了我的项目的大部分,我一直在把代码推到我的仓库中。这个问题突然出现了。这是我在终端中得到的消息
它到达这一点,并在这里停留了很长一段时间:

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

字符串
最后,这是完整的信息:

$ 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'

3pvhb19x

3pvhb19x1#

1.在应用的根文件夹中创建.gitignore文件。
1.插入这一行:/node_modules
1.提交你的修改并将它们推送到git。

*如果你在创建.gitignore文件之前已经提交了一次,你应该关闭终端然后再次提交。
编辑
package.json文件包含了你所有的依赖。当你需要在其他设备上下载你的项目时,你只需要运行npm install-它会自动生成node_modules。

6qfn3psc

6qfn3psc2#

/node_modules文件夹不应该在Git中。要排除Git跟踪该文件夹,您需要在项目的根目录下创建一个.gitignore文件,并在该文件中添加以下行:

/node_modules

字符串
然后再次提交您的更改并推送到存储库。

相关问题