Skip to content

Instantly share code, notes, and snippets.

@JBlackCat
Last active August 29, 2015 14:22
Show Gist options
  • Save JBlackCat/8d399991b64fad79b313 to your computer and use it in GitHub Desktop.
Save JBlackCat/8d399991b64fad79b313 to your computer and use it in GitHub Desktop.
Make NodeJs file executable in shell

##Inside executable file to start

#!/usr/bin/env node

//Define Node Native Modules

//Define Third-Party Modules

(function(){
  "use strict";
  var commandLineArguments = process.argv.slice(2);
})();

##Make file executable, set permissions

chmod u+x myNodeFunc.js

##Symlink to make available globally

    $ cd /usr/local/bin && ln -s ~/path/to/myNodeFunc.js yourSymlinkNameHere

##Add /usr/local/bin to $PATH
View your path variable
bash $ echo $PATH

If needs to be added add
bash PATH=$PATH:/usr/local/bin to your ~/.bashrc file

Once saved reload your .bashrc file
bash source ~/.bashrc Or open a new terminal window

Then check $PATH to enusre it updated correcty
bash $ echo $PATH

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