Reputation: 39
I have a nodeJs app which uses a sysconfig.ts file to store some system info etc. In javascript i could require this file in any modulei like via
const config = require('../../config/sysconfig')
this works for the first file, but if i try to do this in a subsequent file get the following error
TS2451: Cannot redeclare block-scoped variable 'config'.
Ok the simple fix is to call the config different in everyfile but i dont think this is the best solution for this problem. Here is what my config file looks like
module.exports = {
'host': '127.0.0.1',
'port': '8080',
'portSecure': '443',
'tokenlife': '5min'}
Upvotes: 0
Views: 1912
Reputation: 834
you can use something like this:
const config = {
host:"127.0.0.1",
port: "8080",
portSecure: "443",
tokenlife: "5min"
}
export default config;
// and import like this
import config from "./yourconfigpath/configFile"
Upvotes: 2