Node.js Heroku是否部署子目录?
我正在尝试部署一个节点应用程序,但我的代码在结构上遇到了问题。该应用程序是git在顶级初始化的,看起来像:Node.js Heroku是否部署子目录?,node.js,git,heroku,Node.js,Git,Heroku,我正在尝试部署一个节点应用程序,但我的代码在结构上遇到了问题。该应用程序是git在顶级初始化的,看起来像: App (git tracked in remote repo) - .git - server - client - plugin - extras 由于Heroku需要我使用package.json构建文件直接推送服务器目录,因此我不确定如何设置目录。我希望能够从“App/server”文件夹中部署heroku,但仍然可以像现在一样拉/推整个应用程序: App (git tracke
App (git tracked in remote repo)
- .git
- server
- client
- plugin
- extras
由于Heroku需要我使用package.json构建文件直接推送服务器目录,因此我不确定如何设置目录。我希望能够从“App/server”文件夹中部署heroku,但仍然可以像现在一样拉/推整个应用程序:
App (git tracked in remote repo)
- .git
- server (can run 'git push heroku master' for just this folder)
- .git (?)
- client
- plugin
- extras
我怎样才能最简单地做到这一点?我读过关于git子模块的文章,但这看起来很混乱,我想确定一下。非常感谢git nub的支持。我认为git子树应该可以工作:
git子树推送——前缀服务器heroku master
额外资源:
包.json
和存储库根目录中的锁文件,否则部署会失败
但是,您可以在repo的根目录中设置一个package.json
,安装子目录的依赖项并运行它们的相关命令
例如,使用Thread,您可以在根目录中放置一个空的Thread.lock
,以及一个package.json
,如:
{
"name": "my-project",
"version": "0.1.0",
"private": true,
"scripts": {
"postinstall": "yarn --cwd server --production=false install",
"build": "yarn --cwd server serve"
}
}
--production=false
,否则不会发生这种情况,因为在Heroku的环境中,NODE_ENV
被设置为production
。或者,您可以使用git子树
在GitHub上创建Heroku
分支:
git subtree push --prefix server origin heroku
然后可以使用。只需使用按钮将app.json
和README.md
添加到服务器目录:
[![Deploy](https://www.herokucdn.com/deploy/button.png)](https://heroku.com/deploy)
让Heroku来处理剩下的事情。你能分享更多关于如何让这个按钮在子文件夹中工作的信息吗?我的子文件夹中有app.json和README.md,但是链接仍然试图从根目录中获取app.jsondirectory@ScottCarlson在主
README.md
中,将按钮标记更改为[![Deploy](https://www.herokucdn.com/deploy/button.svg)](https://heroku.com/deploy?template=https://github.com/roninbar/kwik-e-mart/tree/heroku)
(用您的GitHub用户名/repo替换roninbar/kwik-e-mart
。@ScottCarlson或者,在单击按钮之前切换到GitHub中的heroku
分支。