follow these examples:
gh repo clone dotenv-org/examples
| API_KEY=api-key-123456789 |
| class Client { | |
| constructor(apiKey) { | |
| this.apiKey = apiKey | |
| } | |
| report(err) { | |
| console.log(this.apiKey, err) | |
| } | |
| } | |
| export default new Client(process.env.API_KEY) |
follow these examples:
gh repo clone dotenv-org/examples
| import dotenv from 'dotenv' | |
| dotenv.config() // this will NOT load process.env before errorReporter is loaded. | |
| // ES6 modules are not intuitive like that. see valid.mjs for proper configuration | |
| import errorReporter from './errorReporter.mjs' | |
| errorReporter.report(new Error('documented example')) |
| import 'dotenv/config' | |
| import errorReporter from './errorReporter.mjs' | |
| errorReporter.report(new Error('documented example')) |