0

I have my index.js file, where I have required my config.json file like this:

const config = require("../config.json");

config.json is just json file. Then I have imported my custom class like this:

let myClass = require('./myClass.js');

If I then need access to my config in myClass.js and put there same require like in my index.js, it gives me error:

Cannot redeclare block-scoped variable 'config'.

But if I don't place there that require, then on NodeJS running, it gives me error:

config is not defined

So, how can I use my config.json (or any package) with require, without renaming it in every file?

Thanks!

Petr Marek
  • 595
  • 5
  • 19
  • Does this answer your question? https://stackoverflow.com/questions/35758584/cannot-redeclare-block-scoped-variable-typescript – Christian Feb 16 '21 at 06:47
  • Please show a larger context to this code. It appears that there's another definition of the `config` variable somewhere in this same block that is conflicting and you are not allowed to redefine it in the same scope. – jfriend00 Feb 16 '21 at 07:44

0 Answers0