resolveEntityFromPath is not a function
-
Hi, there. I'm facing the following problem while trying to render a report with a template using an asset added from the web client and with the embed code provided by the client itself:
TypeError: reporter.folders.resolveEntityFromPath is not a function
at readAsset (.../node_modules/jsreport-assets/lib/assets.js:183:43)
at convert (.../node_modules/jsreport-assets/lib/assets.js:61:5)
at .../node_modules/async-replace/async-replace.js:63:26
at .../node_modules/async/lib/async.js:718:13
at async.forEachOf.async.eachOf (.../node_modules/async/lib/async.js:233:13)
at _parallel (.../node_modules/async/lib/async.js:717:9)
at Object.async.parallel (.../node_modules/async/lib/async.js:731:9)
at module.exports (.../node_modules/async-replace/async-replace.js:71:11)
at tryCatcher (.../node_modules/bluebird/js/release/util.js:16:23)
at ret (eval at makeNodePromisifiedEval (.../node_modules/bluebird/js/release/promisify.js:184:12), <anonymous>:13:39)
at evaluateAssets (.../node_modules/jsreport-assets/lib/assets.js:67:24)
at Object.<anonymous> (.../node_modules/jsreport-assets/lib/assets.js:391:34)My jsreport.config.json looks like this:
{
"httpPort": 3000,
"store": {
"provider": "fs"
},
"blobStorage": {
"provider": "fs"
},
"logger": {
"console": {
"transport": "console",
"level": "debug"
},
"file": {
"transport": "file",
"level": "info",
"filename": "logs/reporter.log"
},
"error": {
"transport": "file",
"level": "error",
"filename": "logs/error.log"
}
},
"allowLocalFilesAccess": true,
"reportTimeout": 60000,
"extensions": {
"authentication": {
"cookieSession": {},
"admin": {
"username": "admin",
"password": "password"
},
"enabled": false
},
"assets": {
"publicAccessEnabled": true
}
}
}Also, if I use an external URL the reports get rendered, but after downloading the generated HTML and opening it all links to the external resources are broken (but work fine from preview tab after running it).
Please advice. Thanks in advance!
-
It looks you use a newer version of jsreport assets extension with an older version of jsreport(core).
Please share the jsreport version. Did you install some extensions explicitly?
The best would be if you paste here the lines jsreport writes to the output during init.
Thank you
-
Yes, I've followed the instructions found at https://github.com/jsreport/jsreport-assets and ran 'npm install jsreport-assets --production' in my jsreport installation directory.
Here's the full start output with the errors:
rads@RAdS-T4500:~...$ jsreport start
(node:15339) Warning: Accessing non-existent property 'padLevels' of module exports inside circular dependency
(Usenode --trace-warnings ...
to show where the warning was created)
2020-08-03T19:00:34.236Z - info: Initializing jsreport@2.8.0 in development mode using configuration file: jsreport.config.json
2020-08-03T19:00:34.238Z - info: Searching for available extensions in .../
2020-08-03T19:00:34.247Z - info: Extensions location cache contains up to date information, skipping crawling in .../
2020-08-03T19:00:34.287Z - info: Found 35 extensions
2020-08-03T19:00:34.418Z - debug: Writing extension locations cache to /tmp/jsreport/core/locations.json
2020-08-03T19:00:34.420Z - debug: Discovered 35 extensions
2020-08-03T19:00:34.529Z - info: Setting dedicated-process (process based) strategy for rendering. Please visit http://jsreport.net/learn/configuration for information how to get more performance.
2020-08-03T19:00:34.538Z - debug: Extension authentication@2.5.0 is disabled, skipping
2020-08-03T19:00:34.538Z - info: Using extension cli@2.2.3
2020-08-03T19:00:34.545Z - info: Using extension debug@2.1.3
2020-08-03T19:00:34.552Z - info: Using extension express@2.6.0
2020-08-03T19:00:34.667Z - info: Using extension freeze@2.0.0
2020-08-03T19:00:34.670Z - info: Using extension handlebars@2.1.0
2020-08-03T19:00:34.672Z - info: Using extension import-export@1.6.0
2020-08-03T19:00:34.715Z - info: Using extension jsrender@2.1.1
2020-08-03T19:00:34.715Z - info: Using extension tags@2.3.0
2020-08-03T19:00:34.718Z - info: Using extension templates@2.3.3
2020-08-03T19:00:34.720Z - info: Using extension authorization@2.3.0
2020-08-03T19:00:34.723Z - debug: Extension authorization@2.3.0 was disabled
2020-08-03T19:00:34.723Z - info: Using extension base@2.0.2
2020-08-03T19:00:34.724Z - info: Using extension browser-client@2.2.2
2020-08-03T19:00:34.726Z - info: Using extension child-templates@1.3.2
2020-08-03T19:00:34.730Z - info: Using extension chrome-pdf@1.8.0
2020-08-03T19:00:34.808Z - debug: Chrome strategy is dedicated-process
2020-08-03T19:00:34.808Z - info: Using extension data@2.2.0
2020-08-03T19:00:34.809Z - info: Using extension docx@2.6.0
2020-08-03T19:00:34.813Z - info: Using extension fs-store@2.8.0
2020-08-03T19:00:34.922Z - info: Using extension licensing@2.2.2
2020-08-03T19:00:34.925Z - info: Using extension pdf-utils@1.7.0
2020-08-03T19:00:35.005Z - info: Using extension pptx@0.6.0
2020-08-03T19:00:35.009Z - info: Using extension reports@2.3.0
2020-08-03T19:00:35.013Z - info: Using extension static-pdf@0.3.1
2020-08-03T19:00:35.016Z - info: Using extension studio@2.8.0
2020-08-03T19:00:35.081Z - debug: studio request logs are enabled (flush interval: 2000)
2020-08-03T19:00:35.083Z - info: Using extension text@2.0.0
2020-08-03T19:00:35.084Z - info: Using extension version-control@1.4.0
2020-08-03T19:00:35.141Z - info: Using extension assets@1.6.0
2020-08-03T19:00:35.149Z - info: Using extension html-to-xlsx@2.6.0
2020-08-03T19:00:35.394Z - info: html-to-xlsx detected chrome as available html engine
2020-08-03T19:00:35.395Z - info: Using extension scheduling@2.3.0
2020-08-03T19:00:35.430Z - info: Using extension scripts@2.4.0
2020-08-03T19:00:35.433Z - info: Using extension studio-theme-dark@0.3.0
2020-08-03T19:00:35.434Z - info: Using extension xlsx@2.3.1
2020-08-03T19:00:35.555Z - info: Using extension public-templates@2.1.0
2020-08-03T19:00:35.556Z - debug: Extension public-templates@2.1.0 was disabled
2020-08-03T19:00:35.556Z - info: Using extension resources@2.0.4
2020-08-03T19:00:35.557Z - info: Using extension sample-template@2.5.1
2020-08-03T19:00:35.559Z - info: Using general timeout for rendering (reportTimeout: 60000)
2020-08-03T19:00:35.559Z - info: Using fs provider for template store.
2020-08-03T19:00:35.565Z - info: fs store is persisting using fs
2020-08-03T19:00:35.567Z - info: fs store is synchronizing using fs
2020-08-03T19:00:35.575Z - info: fs store is loading data
2020-08-03T19:00:35.637Z - debug: fs store sync is configured to use polling for files watcher
2020-08-03T19:00:35.714Z - info: fs store is initialized successfully
2020-08-03T19:00:35.727Z - debug: studio default theme is: light
2020-08-03T19:00:35.740Z - info: Creating default express app.
2020-08-03T19:00:35.762Z - info: jsreport server successfully started on http port: 3000
2020-08-03T19:00:35.764Z - info: fs store emits sockets to synchronize underlying changes with studio
2020-08-03T19:00:35.779Z - info: Verifying license key free
2020-08-03T19:00:35.781Z - info: Using free license
2020-08-03T19:00:35.787Z - debug: Creating samples is disabled
2020-08-03T19:00:35.789Z - info: reporter initialized
2020-08-03T19:00:44.207Z - debug: OData query on templates
2020-08-03T19:00:44.215Z - debug: OData query on folders
2020-08-03T19:00:44.223Z - debug: OData query on tags
2020-08-03T19:00:44.226Z - debug: OData query on data
2020-08-03T19:00:44.227Z - debug: OData query on assets
2020-08-03T19:00:44.229Z - debug: OData query on scripts
2020-08-03T19:00:44.238Z - debug: OData query on xlsxTemplates
2020-08-03T19:00:44.240Z - debug: OData query on schedules
2020-08-03T19:00:44.261Z - debug: OData query on settings
2020-08-03T19:00:44.778Z - debug: OData query on templates
2020-08-03T19:03:21.253Z - info: Starting rendering request 1 (user: null)
2020-08-03T19:03:21.256Z - info: Rendering template { name: broker-report, recipe: html, engine: handlebars, preview: true }
2020-08-03T19:03:21.258Z - debug: Adding sample data r1xrvPAWZD
2020-08-03T19:03:21.262Z - debug: Resources not defined for this template.
2020-08-03T19:03:21.265Z - debug: Base url not specified, skipping its injection.
2020-08-03T19:03:21.272Z - error: Rendering request 1 finished with error in 19 ms
2020-08-03T19:03:21.273Z - error: Error when processing render request 1 reporter.folders.resolveEntityFromPath is not a function TypeError: reporter.folders.resolveEntityFromPath is not a function
at readAsset (.../node_modules/jsreport-assets/lib/assets.js:183:43)
at convert (.../node_modules/jsreport-assets/lib/assets.js:61:5)
at .../node_modules/async-replace/async-replace.js:63:26
at .../node_modules/async/lib/async.js:718:13
at async.forEachOf.async.eachOf (.../node_modules/async/lib/async.js:233:13)
at _parallel (.../node_modules/async/lib/async.js:717:9)
at Object.async.parallel (.../node_modules/async/lib/async.js:731:9)
at module.exports (.../node_modules/async-replace/async-replace.js:71:11)
at tryCatcher (.../node_modules/bluebird/js/release/util.js:16:23)
at ret (eval at makeNodePromisifiedEval (.../node_modules/bluebird/js/release/promisify.js:184:12), <anonymous>:13:39)
at evaluateAssets (.../node_modules/jsreport-assets/lib/assets.js:67:24)
at Object.<anonymous> (.../node_modules/jsreport-assets/lib/assets.js:391:34)
2020-08-03T19:03:21.275Z - error: Error during processing request at http://localhost:3000/api/report/broker-report
2020-08-03T19:03:24.842Z - info: Starting rendering request 2 (user: null)
2020-08-03T19:03:24.843Z - info: Rendering template { name: broker-report, recipe: html, engine: handlebars, preview: true }
2020-08-03T19:03:24.850Z - debug: Adding sample data r1xrvPAWZD
2020-08-03T19:03:24.860Z - debug: Resources not defined for this template.
2020-08-03T19:03:24.861Z - debug: Base url not specified, skipping its injection.
2020-08-03T19:03:24.866Z - error: Rendering request 2 finished with error in 24 ms
2020-08-03T19:03:24.867Z - error: Error when processing render request 2 reporter.folders.resolveEntityFromPath is not a function TypeError: reporter.folders.resolveEntityFromPath is not a function
at readAsset (.../node_modules/jsreport-assets/lib/assets.js:183:43)
at convert (.../node_modules/jsreport-assets/lib/assets.js:61:5)
at .../node_modules/async-replace/async-replace.js:63:26
at .../node_modules/async/lib/async.js:718:13
at async.forEachOf.async.eachOf (.../node_modules/async/lib/async.js:233:13)
at _parallel (.../node_modules/async/lib/async.js:717:9)
at Object.async.parallel (.../node_modules/async/lib/async.js:731:9)
at module.exports (.../node_modules/async-replace/async-replace.js:71:11)
at tryCatcher (.../node_modules/bluebird/js/release/util.js:16:23)
at ret (eval at makeNodePromisifiedEval (.../node_modules/bluebird/js/release/promisify.js:184:12), <anonymous>:13:39)
at evaluateAssets (.../node_modules/jsreport-assets/lib/assets.js:67:24)
at Object.<anonymous> (.../node_modules/jsreport-assets/lib/assets.js:391:34)
2020-08-03T19:03:24.870Z - error: Error during processing request at http://localhost:3000/api/report/broker-report
2020-08-03T19:03:30.376Z - info: Starting rendering request 3 (user: null)
2020-08-03T19:03:30.378Z - info: Rendering template { name: broker-report, recipe: html, engine: handlebars, preview: true }
2020-08-03T19:03:30.379Z - debug: Adding sample data r1xrvPAWZD
2020-08-03T19:03:30.382Z - debug: Resources not defined for this template.
2020-08-03T19:03:30.384Z - debug: Base url not specified, skipping its injection.
2020-08-03T19:03:30.386Z - error: Rendering request 3 finished with error in 10 ms
2020-08-03T19:03:30.388Z - error: Error when processing render request 3 reporter.folders.resolveEntityFromPath is not a function TypeError: reporter.folders.resolveEntityFromPath is not a function
at readAsset (.../node_modules/jsreport-assets/lib/assets.js:183:43)
at convert (.../node_modules/jsreport-assets/lib/assets.js:61:5)
at .../node_modules/async-replace/async-replace.js:63:26
at .../node_modules/async/lib/async.js:718:13
at async.forEachOf.async.eachOf (.../node_modules/async/lib/async.js:233:13)
at _parallel (.../node_modules/async/lib/async.js:717:9)
at Object.async.parallel (.../node_modules/async/lib/async.js:731:9)
at module.exports (.../node_modules/async-replace/async-replace.js:71:11)
at tryCatcher (.../node_modules/bluebird/js/release/util.js:16:23)
at ret (eval at makeNodePromisifiedEval (.../node_modules/bluebird/js/release/promisify.js:184:12), <anonymous>:13:39)
at evaluateAssets (.../node_modules/jsreport-assets/lib/assets.js:67:24)
at Object.<anonymous> (.../node_modules/jsreport-assets/lib/assets.js:391:34)
2020-08-03T19:03:30.391Z - error: Error during processing request at http://localhost:3000/api/report/broker-report
2020-08-03T19:03:56.156Z - debug: OData update on templates
2020-08-03T19:03:56.218Z - debug: OData query on templates
2020-08-03T19:03:58.472Z - info: Starting rendering request 4 (user: null)
2020-08-03T19:03:58.473Z - info: Rendering template { name: broker-report, recipe: html, engine: handlebars, preview: true }
2020-08-03T19:03:58.474Z - debug: Adding sample data r1xrvPAWZD
2020-08-03T19:03:58.478Z - debug: Resources not defined for this template.
2020-08-03T19:03:58.479Z - debug: Base url not specified, skipping its injection.
2020-08-03T19:03:58.487Z - debug: Rendering engine handlebars using dedicated-process strategy
2020-08-03T19:03:58.845Z - debug: Compiled template not found in the cache, compiling
2020-08-03T19:03:58.851Z - debug: Executing recipe html
2020-08-03T19:03:58.852Z - debug: Skipping storing report.
2020-08-03T19:03:58.853Z - info: Rendering request 4 finished in 381 ms
^Crads@RAdS-T4500:~...$ jsreport start
(node:15782) Warning: Accessing non-existent property 'padLevels' of module exports inside circular dependency
(Usenode --trace-warnings ...
to show where the warning was created)
2020-08-03T19:13:21.936Z - info: Initializing jsreport@2.8.0 in development mode using configuration file: jsreport.config.json
2020-08-03T19:13:21.938Z - info: Searching for available extensions in .../
2020-08-03T19:13:21.946Z - info: Extensions location cache contains up to date information, skipping crawling in .../
2020-08-03T19:13:21.986Z - info: Found 35 extensions
2020-08-03T19:13:22.125Z - debug: Writing extension locations cache to /tmp/jsreport/core/locations.json
2020-08-03T19:13:22.127Z - debug: Discovered 35 extensions
2020-08-03T19:13:22.229Z - info: Setting dedicated-process (process based) strategy for rendering. Please visit http://jsreport.net/learn/configuration for information how to get more performance.
2020-08-03T19:13:22.237Z - debug: Extension authentication@2.5.0 is disabled, skipping
2020-08-03T19:13:22.237Z - info: Using extension cli@2.2.3
2020-08-03T19:13:22.244Z - info: Using extension debug@2.1.3
2020-08-03T19:13:22.249Z - info: Using extension express@2.6.0
2020-08-03T19:13:22.364Z - info: Using extension freeze@2.0.0
2020-08-03T19:13:22.366Z - info: Using extension handlebars@2.1.0
2020-08-03T19:13:22.368Z - info: Using extension import-export@1.6.0
2020-08-03T19:13:22.411Z - info: Using extension jsrender@2.1.1
2020-08-03T19:13:22.412Z - info: Using extension tags@2.3.0
2020-08-03T19:13:22.414Z - info: Using extension templates@2.3.3
2020-08-03T19:13:22.416Z - info: Using extension authorization@2.3.0
2020-08-03T19:13:22.419Z - debug: Extension authorization@2.3.0 was disabled
2020-08-03T19:13:22.419Z - info: Using extension base@2.0.2
2020-08-03T19:13:22.421Z - info: Using extension browser-client@2.2.2
2020-08-03T19:13:22.422Z - info: Using extension child-templates@1.3.2
2020-08-03T19:13:22.426Z - info: Using extension chrome-pdf@1.8.0
2020-08-03T19:13:22.508Z - debug: Chrome strategy is dedicated-process
2020-08-03T19:13:22.508Z - info: Using extension data@2.2.0
2020-08-03T19:13:22.509Z - info: Using extension docx@2.6.0
2020-08-03T19:13:22.513Z - info: Using extension fs-store@2.8.0
2020-08-03T19:13:22.621Z - info: Using extension licensing@2.2.2
2020-08-03T19:13:22.624Z - info: Using extension pdf-utils@1.7.0
2020-08-03T19:13:22.702Z - info: Using extension pptx@0.6.0
2020-08-03T19:13:22.706Z - info: Using extension reports@2.3.0
2020-08-03T19:13:22.710Z - info: Using extension static-pdf@0.3.1
2020-08-03T19:13:22.714Z - info: Using extension studio@2.8.0
2020-08-03T19:13:22.776Z - debug: studio request logs are enabled (flush interval: 2000)
2020-08-03T19:13:22.778Z - info: Using extension text@2.0.0
2020-08-03T19:13:22.779Z - info: Using extension version-control@1.4.0
2020-08-03T19:13:22.833Z - info: Using extension assets@1.6.0
2020-08-03T19:13:22.840Z - info: Using extension html-to-xlsx@2.6.0
2020-08-03T19:13:23.088Z - info: html-to-xlsx detected chrome as available html engine
2020-08-03T19:13:23.088Z - info: Using extension scheduling@2.3.0
2020-08-03T19:13:23.123Z - info: Using extension scripts@2.4.0
2020-08-03T19:13:23.127Z - info: Using extension studio-theme-dark@0.3.0
2020-08-03T19:13:23.127Z - info: Using extension xlsx@2.3.1
2020-08-03T19:13:23.265Z - info: Using extension public-templates@2.1.0
2020-08-03T19:13:23.266Z - debug: Extension public-templates@2.1.0 was disabled
2020-08-03T19:13:23.266Z - info: Using extension resources@2.0.4
2020-08-03T19:13:23.267Z - info: Using extension sample-template@2.5.1
2020-08-03T19:13:23.270Z - info: Using general timeout for rendering (reportTimeout: 60000)
2020-08-03T19:13:23.270Z - info: Using fs provider for template store.
2020-08-03T19:13:23.276Z - info: fs store is persisting using fs
2020-08-03T19:13:23.277Z - info: fs store is synchronizing using fs
2020-08-03T19:13:23.287Z - info: fs store is loading data
2020-08-03T19:13:23.363Z - debug: fs store sync is configured to use polling for files watcher
2020-08-03T19:13:23.448Z - info: fs store is initialized successfully
2020-08-03T19:13:23.461Z - debug: studio default theme is: light
2020-08-03T19:13:23.474Z - info: Creating default express app.
2020-08-03T19:13:23.499Z - info: jsreport server successfully started on http port: 3000
2020-08-03T19:13:23.500Z - info: fs store emits sockets to synchronize underlying changes with studio
2020-08-03T19:13:23.516Z - info: Verifying license key free
2020-08-03T19:13:23.520Z - info: Using free license
2020-08-03T19:13:23.539Z - error: Error occured during reporter init TypeError: Cannot read property 'publicRoutes' of undefined
at Reporter.<anonymous> (.../node_modules/jsreport-express/lib/routes.js:12:73)
at Reporter.emit (events.js:314:20)
at Function.<anonymous> (.../node_modules/jsreport-assets/lib/assets.js:415:16)
at .../node_modules/listener-collection/lib/listenerCollection.js:171:33
at .../node_modules/listener-collection/lib/listenerCollection.js:151:16
at tryCatcher (.../node_modules/listener-collection/node_modules/bluebird/js/release/util.js:16:23)
at Promise._settlePromiseFromHandler (.../node_modules/listener-collection/node_modules/bluebird/js/release/promise.js:512:31)
at Promise._settlePromise (.../node_modules/listener-collection/node_modules/bluebird/js/release/promise.js:569:18)
at Promise._settlePromise0 (.../node_modules/listener-collection/node_modules/bluebird/js/release/promise.js:614:10)
at Promise._settlePromises (.../node_modules/listener-collection/node_modules/bluebird/js/release/promise.js:693:18)
at Async._drainQueue (.../node_modules/listener-collection/node_modules/bluebird/js/release/async.js:133:16)
at Async._drainQueues (.../node_modules/listener-collection/node_modules/bluebird/js/release/async.js:143:10)
at Immediate.Async.drainQueues [as _onImmediate] (.../node_modules/listener-collection/node_modules/bluebird/js/release/async.js:17:14)
at processImmediate (internal/timers.js:458:21)
An error has occurred when trying to initialize jsreport (2). Cannot read property 'publicRoutes' of undefined (1).
caused by error (2):
-> stack
Error:
at .../node_modules/jsreport-cli/lib/instanceHandler.js:31:29
at async Commander.executeCommand (.../node_modules/jsreport-cli/lib/commander.js:242:22)
caused by error (1):
-> stack
TypeError:
at Reporter.<anonymous> (.../node_modules/jsreport-express/lib/routes.js:12:73)
at Reporter.emit (events.js:314:20)
at Function.<anonymous> (.../node_modules/jsreport-assets/lib/assets.js:415:16)
at .../node_modules/listener-collection/lib/listenerCollection.js:171:33
at .../node_modules/listener-collection/lib/listenerCollection.js:151:16
at tryCatcher (.../node_modules/listener-collection/node_modules/bluebird/js/release/util.js:16:23)
at Promise._settlePromiseFromHandler (.../node_modules/listener-collection/node_modules/bluebird/js/release/promise.js:512:31)
at Promise._settlePromise (.../node_modules/listener-collection/node_modules/bluebird/js/release/promise.js:569:18)
at Promise._settlePromise0 (.../node_modules/listener-collection/node_modules/bluebird/js/release/promise.js:614:10)
at Promise._settlePromises (.../node_modules/listener-collection/node_modules/bluebird/js/release/promise.js:693:18)
at Async._drainQueue (.../node_modules/listener-collection/node_modules/bluebird/js/release/async.js:133:16)
at Async._drainQueues (.../node_modules/listener-collection/node_modules/bluebird/js/release/async.js:143:10)
at Immediate.Async.drainQueues [as _onImmediate] (.../node_modules/listener-collection/node_modules/bluebird/js/release/async.js:17:14)
at processImmediate (internal/timers.js:458:21)
-
Ah ok I see, thank you.
The assets extension is part of the official jsreport package.
This means you don't need to explicitly install it.
What happened is that you have jsreport 2.8.0 but explicitly installed assets extension that is compatible with jsreport >=2.9.0 and not compatible with your current version.Please don't install assets extension explicitly and use the one that is part of the jsreport package.
We will have to make it more clear in the readme.
-
Got it! Thanks for the clarification, @jan_blaha ! :)
Anyways I was being stupid and saving the report from the browser with the Right click > Save as and expecting that the assets URLs would remain the same. (Doh!)
I realized I need to wget it or send a GET request to get the plain original HTML processed report without having to save the resources locally.
Anyways, thank you so much for the quick replies!