As you suggested using the pkg tool it is hard to create an exe file, can you provide an alternative way to achieve my requirements?
Thanks @bjrmatos26 in advance for your time and help.
As you suggested using the pkg tool it is hard to create an exe file, can you provide an alternative way to achieve my requirements?
Thanks @bjrmatos26 in advance for your time and help.
Hello @jan_blaha @bjrmatos26
I have downloaded the js report npm package and used that with the node app to generate a report, so , in summary, node app will get a request, process some database operation, and then with this data and template name report will be rendered.
I have created one basic template named test which is just containing "<h1>Hello</h1>". we know this will be stored in the data folder of the root repository. and I have also included configuration file report settings. All things work fine when I am running on the local machine.
Overall server.js file. [ when "/report" path will be called test report will be displayed]
if (process.env.JSREPORT_CLI) {
module.exports = jsreport
}
else {
jsreport.init().then(() => {
// start here
})
}
app.get('/report', (req, res) => {
console.log("------ report endpoint is called -----")
jsreport.render({
template: {
name: test,
engine: 'handlebars',
recipe: 'chrome-pdf'
},
data: {}
}).then((result) => {
console.log("-------------------------------------------------------", result.content,);
res.send(result.content);
})
})
Problem starts here:
--> When I am trying to convert this app into an executable file using the pkg tool and following the command "pkg . --debug " the exe file is not able to render a template. As we know if we have to include a data folder in the executable file I have put it in the package.json file.
In package.json file: (So templates should be inside exe file)
"pkg": {
"assets": [
"./data/*/",
]
}
--> Error I am getting:
(because) unable to find specified template (test)
Error: Unable to find specified template (test)
at C:\snapshot\reporting\node_modules@jsreport\jsreport-core\lib\shared\createError.js:10:13