Found this little tip this morning to make it easier to use command line scripts written in node.js. Instead of having your node.js file(s) and invoking it using “node myfile.js” on the Mac you can simply do the following:
- At the top of the file as the first line add: #!/bin/usr/env node
- Make the file executable using chmod +x myfile.js
- Invoke away
Now the file is usable by simply using myfile.js.