如何将 MERN 堆栈应用程序部署到 GitHub 和 Heroku?
How to deploy MERN stack app to GitHub and Heroku?
我使用 ReactJS 进行前端开发已经有一段时间了,现在我决定将我的技能升级到 MERN 的全栈(MongoDB - Express - React - Node)。我已成功开发我的 MERN 应用程序,但部署过程失败。
我尝试使用“从 GitHub 到 Heroku”的方法,您首先将所有内容上传到 GitHub,然后从那里在 Heroku 上使用它。我什至无法将我的文件结构上传到 GitHub,所以我正在寻求帮助。
我想知道我的文件结构可能有误所以这里有一些屏幕截图让您明白了:
当我尝试上传到 GitHub 时,我收到此警告:
warning: adding embedded git repository: client
跟进一堆提示...为什么会这样?我认为客户端和服务器都有单独的 .gitignore 文件,这可能是问题所在吗?
cd (to the directory where client and server are)
git init
git add .
此时我不断收到警告:
warning: adding embedded git repository: client
hint: You've added another git repository inside your current repository.
hint: Clones of the outer repository will not contain the contents of
hint: the embedded repository and will not know how to obtain it.
hint: If you meant to add a submodule, use:
hint:
hint: git submodule add <url> client
hint:
hint: If you added this path by mistake, you can remove it from the
hint: index with:
hint:
hint: git rm --cached client
hint:
hint: See "git help submodule" for more information.
感谢您的帮助。
我想你使用了 create-react-app。 create-react-app 还会启动一个 git 存储库。
只需删除./client/.git
,然后再做。应该没问题。
cd ./client
rm -rf .git
我使用 ReactJS 进行前端开发已经有一段时间了,现在我决定将我的技能升级到 MERN 的全栈(MongoDB - Express - React - Node)。我已成功开发我的 MERN 应用程序,但部署过程失败。
我尝试使用“从 GitHub 到 Heroku”的方法,您首先将所有内容上传到 GitHub,然后从那里在 Heroku 上使用它。我什至无法将我的文件结构上传到 GitHub,所以我正在寻求帮助。
我想知道我的文件结构可能有误所以这里有一些屏幕截图让您明白了:
当我尝试上传到 GitHub 时,我收到此警告:
warning: adding embedded git repository: client
跟进一堆提示...为什么会这样?我认为客户端和服务器都有单独的 .gitignore 文件,这可能是问题所在吗?
cd (to the directory where client and server are)
git init
git add .
此时我不断收到警告:
warning: adding embedded git repository: client
hint: You've added another git repository inside your current repository.
hint: Clones of the outer repository will not contain the contents of
hint: the embedded repository and will not know how to obtain it.
hint: If you meant to add a submodule, use:
hint:
hint: git submodule add <url> client
hint:
hint: If you added this path by mistake, you can remove it from the
hint: index with:
hint:
hint: git rm --cached client
hint:
hint: See "git help submodule" for more information.
感谢您的帮助。
我想你使用了 create-react-app。 create-react-app 还会启动一个 git 存储库。
只需删除./client/.git
,然后再做。应该没问题。
cd ./client
rm -rf .git