Renaming an app https://devcenter.heroku.com/articles/renaming-apps
$ heroku apps:rename newname
This guide walks through the necessary steps to deploy your full stack Node.js application to Heroku!
To begin with, you'll need a git repository initialized locally with your basic web server code working and committed.
There are a couple of ways to do this.
Run git init
locally in the folder with your web server files.
Commit all changes (if you haven't already with the above steps) using git add .
and git commit -am "<message>"
. If you haven't run into any errors at this point, you should be able to proceed to the next section.
.gitignore
file if you don't have one already. This file will allow you to tell git to not track files such as those in the node_modules
folder..gitignore
. Inside of that file, add node_modules/
as the first line and save the file. Now, git should no longer track node_modules
files.Log in to Heroku.
If you are a windows user open the cmd.exe (NOT Git Bash) and type heroku login
. Keep this command prompt open in the background. Then, open Git Bash and navigate to the folder with your code.
If you are a mac open terminal and type the command heroku login
. Enter your Heroku credentials and proceed with all the below steps in terminal. Navigate to the folder with your code.
Run the command: git remote –v
.
Run the command heroku create
.
Run git remote –v
again.
heroku
remote.Ensure that your package.json
file is set up correctly. It must have a start
script and all dependencies defined. E.g.:
{
"name": "starwars",
"version": "1.0.0",
"description": "Helps you find the characters you are looking for",
"main": "server.js",
"dependencies": {
"body-parser": "^1.15.0",
"express": "^4.13.4"
},
"scripts": {
"start": "node server.js"
}
}
Ensure your web server is starting with a dynamic port.
var PORT = process.env.PORT || 3000;
...
app.listen(PORT, function() {
process.env.PORT
) if it exists, so that when your app starts on heroku's machine it will start listening on the appropriate port.Commit any changes you've made up until this point using git commit -am "<message>"
Run the command git push heroku master
. A series of processes will be initiated. Once the process is complete note the name of the app.
Log in to your Heroku account at www.heroku.com . You will see a list or a (single) app. Note the one that has the same funky name as you saw in bash. Click on it.
Click on settings. Then, scroll down until you see the part that says: "Domains". Note the URL listed under Heroku Domain.
Finally, go in your browser to the URL listed under the Heroku Domain. If all went well you should see your website!