I did a js script to transform a JSON object to an excel file. The script works when I execute it in command line with a mock JSON object, but when I call it from the node "file function" of node-red, I get the error: "TypeError: XLSX.utils.json_to_sheet is not a function". Here is my script :
const XLSX = require('xlsx');
const wb = { SheetNames: [], Sheets: {} };
const json = msg.questions;
console.log(json);
const ws = XLSX.utils.json_to_sheet(json);
const sheetName = "test sheet";
XLSX.utils.book_append_sheet(wb, ws, sheetName);
XLSX.writeFile(wb, 'output.xlsx');