Skip to content

Instantly share code, notes, and snippets.

@grantmichaels
Forked from johnschimmel/gist:1941724
Created May 13, 2012 20:49
Show Gist options
  • Save grantmichaels/2690116 to your computer and use it in GitHub Desktop.
Save grantmichaels/2690116 to your computer and use it in GitHub Desktop.
Developing locally and deploying NodeJS on Heroku

Initial NodeJS setup

with heroku toolbelt installed run following in code directory (via Terminal)

npm install
git init
git add .
git commit -am "initial commit"
foreman start

The site is now running, visit in browser localhost:5000

Development

As you program and make changes you only need to save your files and start the server with the command

foreman start

Create a .gitignore file with the content

node_modules

Quick one line to create the .gitignore file

echo "node_modules" > .gitignore

It is a good idea to save your changes as your code progresses

git add .
git commit -am "I made some great code."

Open your browser to localhost:5000

Deploy (first time)

Create a new app on Heroku's Cedar stack, run

heroku create --stack cedar

This will create a new app on Heroku with a funny name, you can rename it

heroku rename <yourAppNameHere>

Commit your code if you have not already, add files if needed

git add .
git commit -am "code is ready to deploy"

Now push to Heroku

git push heroku master
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment