I am getting this error while trying to get a QR code. I know I have run an npm install for all of the packages I am using which is the fix I have seen other places. Can someone let me know why I am getting this error?
throw new ERR_REQUIRE_ESM(filename, parentPath, packageJsonPath);^ Error [ERR_REQUIRE_ESM]: Must use import to load ES Module: /Users/namey/myapp/node_modules/tempfile
const QRCode = require('qrcode')
const fs = require('fs');
const path = require('path');
const tempFile = require('tempfile');
module.exports = {
generate: async (host, vin) => {
let url = `https://${host}/VIN/${vin}`;
let file = await generate(url, vin);
return file;
// let key = `/qrcodes/${vin}.png`
// let data = await sendToS3(file, key);
// return data.Location;
}
}
let generate = (url, vin) => {
return new Promise(async (resolve, reject)=>{
// let file = `./qrcodes/${vin}_${Math.floor(Math.random()*100000)}.png`;
let file = tempFile('.png');
QRCode.toFile(file,url,{},(err, result)=>{
console.log(file);
resolve(file);
})
});
}
Via Active questions tagged javascript - Stack Overflow https://ift.tt/2FdjaAW
Comments
Post a Comment