I would like to include a couple of JSON files in my JavaScript code that are in the same directory as my JavaScript source file.
If I wanted to include another JavaScript file I could simply use require
.
Now I'm using readFileSync
and __dirname
to get the JSON, which I think is an ugly way to do it.
Is there something similar for require that enables me to load a JSON file?
Question&Answers:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…