Handy Tricks & Tools

Pushing a Node App to Heroku

If you're used to pushing Rails apps to Heroku, deploying your first Node app could be a pretty frustrating experience. 

It was for me. 

Here's some tricks to help you deploy:

  • Add Node as an engine dependency in your package.json file:
"engines": {
"node": "4.1.1"
},
  • Delete your node modules and reinstall all your dependencies in your production environment. To do this, run `rm -rf node_modules` and `npm install --production`
  • Double-check everything worked. Run `heroku local web` and visit http://localhost:5000 to see your app as it will appear once deployed.
  • If everything looks good, deploy as usual.
$ git add .
$ git commit -m "Added a Procfile."
$ heroku login
Enter your Heroku credentials.
...
$ heroku create
Creating arcane-lowlands-8408... done, stack is cedar
http://arcane-lowlands-8408.herokuapp.com/ | git@heroku.com:arcane-lowlands-8408.git
Git remote heroku added
$ git push heroku master
...
-----> Node.js app detected
...
-----> Launching... done
 http://arcane-lowlands-8408.herokuapp.com deployed to Heroku

For more information on deploying Node apps to Heroku, read through Heroku's very helpful instructions.

Trash Command Line Tool

I'm going to be honest here. 

`rm -rf` scares the poo out of me. I'm convinced that at some point I'm going to delete my entire computer. As if in one moment I'll be working diligently and the next everything I hold dear will be sucked into a permanent black hole. 

It's scary. Be honest. It scares you too. 

So I don't use `rm` unless I absolutely have to. 

Instead, I use this awesome little Trash command line tool for OS X.  

You can install it using Homebrew.

Install Trash

In your terminal, type `brew install trash`. 

Boom. It's just that easy. 

How To Use Trash

When you have a file or directory you'd like to remove, simply type `trash <your_file_name>`. Type `ls` in your current directory to double-check it's gone (it will be) and then click on your trash bin to find it.

If it turns out you didn't want to delete that file permanently the second after you hit return, have no fear. All your files are 100% retrievable.