i get the error while running the command like this
hi guys, i get an error like this while running the command in my backend. Command failed: hackmyresume build ./resume-sample/res.json TO ./resume-sample/resume-modern.html -t node_modules/jsonresume-theme-modern -o html /home/kuber/.nvm/versions/node/v16.20.2/lib/node_modules/hackmyresume/node_modules/chalk/index.js:2 const escapeStringRegexp = require('escape-string-regexp'); ^
Error [ERR_REQUIRE_ESM]: require() of ES Module /home/kuber/.nvm/versions/node/v16.20.2/lib/node_modules/escape-string-regexp/index.js from /home/kuber/.nvm/versions/node/v16.20.2/lib/node_modules/hackmyresume/node_modules/chalk/index.js not supported.
Instead change the require of /home/kuber/.nvm/versions/node/v16.20.2/lib/node_modules/escape-string-regexp/index.js in /home/kuber/.nvm/versions/node/v16.20.2/lib/node_modules/hackmyresume/node_modules/chalk/index.js to a dynamic import() which is available in all CommonJS modules.
at Object.
const hackmyresume = require('hackmyresume'); const eleganttheme = require('jsonresume-theme-elegant'); const moderntheme = require('jsonresume-theme-modern'); const fs = require('fs').promises; const { exec } = require('child_process'); const { promisify } = require('util');
const execPromise = promisify(exec); async function generateResume(resumeFile, theme, format) { const resumeString = JSON.stringify(resumeFile);
await fs.writeFile(__dirname+'/resume-sample/res.json', resumeString);
// Create a temporary file name for the output
const tmpFile = ${__dirname}/resume-sample/resume-${theme}.${format};
// Create a new hackmyresume process const themes={ 'modern': moderntheme, 'elegant': eleganttheme, };
const command = hackmyresume build ./resume-sample/res.json TO ./resume-sample/resume-${theme}.html -t node_modules/jsonresume-theme-${theme} -o html;
// Try to execute the command and catch any errors
try {
await execPromise(command);
} catch (error) {
console.error('Error executing hackmyresume command:', error);
throw error;
}
// Try to read the output file as a buffer and catch any errors try { const output = await fs.readFile(tmpFile); return output; // Return the output as a buffer } catch (error) { console.error('Error reading the output file:', error); throw error; }
}
// Example usage:
module.exports = { generateResume, };
Can anyone point out what i'm doing wrong here.