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

Viewed 556

I've deployed my directory to Heroku using git push heroku master, but nothing happens.... Everything up-to-date is what the screen reads.

How can I push to Heroku the exact version that I am running locally, since the local version does the things I want?

4 Answers

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

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 (e.g. NODE_ENV variable)

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.

Please check the branch or remote url of heroku.

In heroku click Deploy tab and find out the branch. Add the remote url in your local machine terminal.

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

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:

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.

first run git add -A to stage all changes, including deletions.

or run git add . to stage all changes, without the deletions.

then git push heroku master will push those staged changes to master and 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.

Related