Create JSreport client server
-
Hello.
I create jsreport to generate PDF is OK now.
I use PKG npm newest version to create EXE file that run a jsreport server.
with command: pkg server.jsserver.js
const jsreport = require('jsreport')() const fs = require('fs') if (process.env.JSREPORT_CLI) { // export jsreport instance to make it possible to use jsreport-cli module.exports = jsreport } else { jsreport.init().then(() => { // running }).catch((e) => { // error during startup console.error(e.stack) fs.writeFileSync("log.txt", e.stack) process.exit(1) }) }
jsreport.config.json
{ "httpPort": 5488, "store": { "provider": "memory" }, "blobStorage": { "provider": "memory" }, "logger": { "console": { "transport": "console", "level": "debug" } }, "allowLocalFilesAccess": true, "reportTimeout": 600000, "templatingEngines": { "numberOfWorkers": 4, "strategy": "http-server" }, "chrome": { "launchOptions": { "args": [] } }, "extensions": { "authentication": { "cookieSession": { "secret": "secret_string" }, "admin": { "username": "admin", "password": "jsreport" }, "enabled": true }, "scripts": { "strategy": "http-server" } } }
The problem is it's ok to start.
In the image:
1 -> successful init
2 -> error i got when create PDF with server running by file created by PKG
(with server running by node server.js its OK)Anyone have an experiment about this issue ?
-
Compiling jsreport (or other complex nodejs apps) into exe is much more complicated.
You can either download our already compiled distributionhttps://github.com/jsreport/jsreport/releases
Or try to use our code that leverages pkg to compile:
jsreport v2
https://github.com/jsreport/jsreport-compilejsreport v3
https://github.com/jsreport/jsreport/blob/master/scripts/compile.js
-
OK. Now i understand that pkg not resolve my problem.
I tried to download this one (https://github.com/jsreport/jsreport/releases) but it cant start. When i open it open command line window and shutdown (exit) imediately. Is that any special in there ?
-
see the documentation
https://jsreport.net/learn/single-file-executable