DEV Community

Discussion on: Adventures of a Hobbyist ~ Part Three

Collapse
4lch4 profile image
Devin W. Leaman

Personally for configurations, I usually have a config.json file with the values I need, since in JavaScript you can require the file and most intellisense modules will pick up all the keys in the file.

Another option is to set environment variables using something like PM2, which is what I use to actually run my node modules. You create a simple pm2.config.json and add the environment variables in there and on startup the values are available with process.env.VARIABLE_NAME.

If you're interested, I'll put a more detailed example in your git repo for you to take a look at.

Collapse
4lch4 profile image
Devin W. Leaman

Also, the beauty of the config.json is there's no more need for the fs module 😊

Collapse
link2twenty profile image
Andrew Bone Author

Any examples would be great, thank you 🙂