I have a node.js
app & have some configurations based on the environment. So decided to use
https://www.npmjs.com/package/config
In accordance, I created a folder named config
at the root level of the app. The folder structure looks like as below
app
-config
--default.json
--local.json
--qa.json
--prod.json
-src
--routes
---products.ts
this is my local.json & default.json
{
"MAX_CONNECTIONS" : 100
}
in product.ts
import { get } from 'config';
// code emitted for brievty
const allowedConnectionsLimit = get<number>('MAX_CONNECTIONS'); //also tried with get("MAX_CONNECTIONS")
But this keeps on throwing the error
error-configuration-property-MAX_CONNECTIONS-is-not-defined
Things tried
- uninstalled config & @types/config
- reinstalled config & @types/config
- moved the config folder inside src
- rebooted the app
- cross checked the filename & the variable name
even then this is throwing the error
Thanks!