Search code examples
node.jsshellcommand-lineconfigconfiguration-files

How to make node.js automatically load config files


In node.js, you can use 'require()' to load your configuration files, but I am tired of having to do that on all my programs. Is there a way to make node.js automatically load config files?


Solution

  • Never mind. I found out you can do that by putting this in your '.bash_profile' or shell configuration file on a unix machine:

    alias node='node -r ./config.js'