​https://www.npmjs.com/package/dotenv​
Properties:
Simple configuration
Values can only be a string or a number
No complicated values
Useful when making minor flags or changes
Human readable
Example:
.envNODE_ENV=productionPORT=3001
If possible use JSON5 over JSON.
From https://github.com/json5/json5​
The JSON5 Data Interchange Format (JSON5) is a superset of JSON that aims to alleviate some of the limitations of JSON by expanding its syntax to include some productions from ECMAScript 5.1.
Properties:
Nested configuration
Uses an already familiar programming paradigm
Human readable
Example:
example.json5{// commentsunquoted: 'and you can quote me on that',singleQuotes: 'I can use "double quotes" here',lineBreaks: "Look, Mom! \No \\n's!",hexadecimal: 0xdecaf,leadingDecimalPoint: .8675309, andTrailing: 8675309.,positiveSign: +1,trailingComma: 'in objects', andIn: ['arrays',],"backwardsCompatible": "with JSON",}
Properties:
Complicated
Overly verbose
Useful for computers interfacing with each other
​https://yaml.org/​
Properties:
Can get complex with the "repeated nodes" syntax
Spacing is important, which can throw off the configuration
Isn't immediately obvious when something is a list/array or a map
​https://en.wikipedia.org/wiki/INI_file​
Properties:
Cannot be deeply nested
; last modified 1 April 2001 by John Doe[owner]name=John Doeorganization=Acme Widgets Inc.​[database]; use IP address in case network name resolution is not workingserver=192.0.2.62port=143file="payroll.dat"
Example: mixing .env and JSON5
When you need a mix of simple and complex data structures?
JSON objects should only be read once.
Environment variables can be read multiple times in the system.
Limit it to just two.
Don't mix too many formats. Too many different rules to remember. Or use different format for communication between services (ie: JSON, or XML files)
No. Unless you have a really good reason.
You have to create a parser.