In a file called data.js, I have a big object array:
var arr = [ {prop1: value, prop2: value},...]
I\'d like to use this array into my Node.js
We can use destructuring to solve your problem.
In file1.js, we create an object array:
var arr = [{ prop1: "beep", prop2: "boop" }];
Then we do the following to export:
module.exports = { arr };
Then in another file, file2.js, we require the array from file1
const f1 = require("./file1");
Log the result to test
console.log(f1.arr);