简体   繁体   English

Localhost:3000版本与Heroku部署版本的显示方式不同-Node.js

[英]Localhost:3000 Version Displayed Differently from Heroku Deployed Version - Node.js

I've deployed my directory to Heroku using git push heroku master , but nothing happens... . Everything up-to-date 我用我的部署目录Heroku的git push heroku master ,但没有任何反应...... . Everything up-to-date . Everything up-to-date is what the screen reads. . Everything up-to-date是屏幕在读什么。

How can I push to Heroku the exact version that I am running locally, since the local version does the things I want? 由于本地版本可以执行我想要的操作,因此我该如何将我在本地运行的确切版本推送到Heroku?

If you are sure that the source codes itself are not the same in these two branches, you can use force push: 如果您确定这两个分支中的源代码本身不相同,则可以使用强制推送:

# Make sure you are on your local master branch
git branch
# Make sure that your remote address is correctly set
git remote -v
# Then force push your master branch to heroku remote master branch
git push heroku master -f

force pushing a branch to a remote will force the remote branch to take on the branch's code and git commit history 强制将分支推送到远程将强制远程分支采用分支的代码和git commit历史记录

But if you don't have access to check the source code, check if Environment Variables are the same on local machine and server or not (eg NODE_ENV variable) 但是,如果您无权检查源代码,请检查环境变量在本地计算机和服务器上是否相同(例如NODE_ENV变量)

Moreover, Double check automatic deployment of heroku (if exists) as well as the node and npm version of both machines and be aware of the command you run on both machines ( npm start or node . or ...) that may have different operations based on envs or so. 此外,仔细检查heroku(如果存在)以及两台机器的节点和npm版本的自动部署,并注意您在两台机器上运行的命令( npm startnode .或...)可能具有不同的操作。基于envs左右。

Since you are not doing anything obviously wrong, something is wrong. 由于您没有做任何明显错误的事情,因此出现了问题。 It is hard to say what it is exactly, without additional investigation. 无需进一步调查,很难说出确切的含义。

I suggest that you clone your project from heroku into a new directory, then copy your local changes from your local branch (which as you said works on 3000 port) into this fresh directory and push all those changes as usual: 我建议您将项目从heroku克隆到新目录中,然后将本地更改(如您所说的在3000端口上工作)从本地分支复制到此新目录中,然后像往常一样推送所有这些更改:

git add -A
git commit -m "some message"
git push

It is also a good idea to diff fresh clone with your currently working directory. 将新克隆与当前工作目录进行比较也是一个好主意。 If tracked files are identical, that would suggest difference between local environment and heroku container configuration. 如果跟踪的文件相同,则表明本地环境和heroku容器配置之间存在差异。

Please check the branch or remote url of heroku. 请检查heroku的分支或远程URL。

In heroku click Deploy tab and find out the branch. 在heroku中,单击Deploy选项卡并找到分支。 Add the remote url in your local machine terminal. 在本地计算机终端中添加远程URL。

1) heroku git:remote -a projectname
2) git status
3) git add .
4) git commit -m "message"
5) git push heroku master

first run git add -A to stage all changes, including deletions. 首先运行git add -A所有更改,包括删除。

or run git add . 或运行git add . to stage all changes, without the deletions. 进行所有更改,而不删除。

then git push heroku master will push those staged changes to master and remote heroku . 然后git push heroku master会将那些分阶段的更改推送到master和remote heroku

this is because, while no changes were staged, there is nothing to push (both branches identical). 这是因为,虽然没有进行任何更改,但是没有任何可推送的内容(两个分支都相同)。

using a visual front-end might help to make it easier to handle. 使用视觉前端可能有助于使其更易于处理。 and maybe consider to setup a local staging environment (where the term staging has a different meaning, than it has within the context of git ), in order to test properly, before pushing files to the live environment. 并且可能考虑设置本地暂存环境(术语staginggit上下文中的含义不同),以便在将文件推送到实时环境之前进行正确的测试。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM