Can not start server - TypeError: Cannot read property 'cwd' of undefined - urgent


  • administrators

    i'm confused, where are you taking these logs? from the console? these logs seems incomplete, i don't see in the logs any reference to the error that you were describing.

    for reference, here are the full logs when a jsreport server starts normally without errors:

    2018-01-23T21:40:27.652Z - info: Initializing jsreport@1.9.2 in development mode using configuration file: none
    2018-01-23T21:40:27.653Z - info: Setting process based strategy for rendering. Please visit http://jsreport.net/learn/configuration for information how to get more performance.
    2018-01-23T21:40:27.687Z - info: Searching for available extensions in /Volumes/DATA/workspace/jsreport/jsreport-designer/
    2018-01-23T21:40:27.800Z - info: Extensions location cache contains up to date information, skipping crawling in /Volumes/DATA/workspace/jsreport/jsreport-designer/node_modules/
    2018-01-23T21:40:30.083Z - info: Found 32 extensions
    2018-01-23T21:40:30.270Z - debug: Writing extension locations cache to /var/folders/0d/wh3hsmm506d5fws_8x_dsj0c0000gn/T/jsreport/core/locations.json
    2018-01-23T21:40:30.271Z - debug: Discovered 32 extensions
    2018-01-23T21:40:30.272Z - info: Using extension fop-pdf
    2018-01-23T21:40:30.608Z - info: Using extension tags
    2018-01-23T21:40:30.684Z - info: Using extension cli
    2018-01-23T21:40:30.692Z - info: Using extension debug
    2018-01-23T21:40:30.709Z - info: Using extension express
    2018-01-23T21:40:32.103Z - info: Using extension authentication
    2018-01-23T21:40:32.746Z - debug: Extension authentication was disabled
    2018-01-23T21:40:32.746Z - info: Using extension handlebars
    2018-01-23T21:40:32.765Z - info: Using extension import-export
    2018-01-23T21:40:34.683Z - info: Using extension jsrender
    2018-01-23T21:40:34.720Z - info: Using extension templates
    2018-01-23T21:40:34.842Z - info: Using extension images
    2018-01-23T21:40:35.090Z - info: Using extension authorization
    2018-01-23T21:40:35.292Z - debug: Extension authorization was disabled
    2018-01-23T21:40:35.292Z - info: Using extension base
    2018-01-23T21:40:35.300Z - info: Using extension fs-store
    2018-01-23T21:40:36.175Z - debug: Extension fs-store was disabled
    2018-01-23T21:40:36.175Z - info: Using extension browser-client
    2018-01-23T21:40:36.250Z - info: Using extension html-to-xlsx
    2018-01-23T21:40:36.807Z - info: Using extension designer-built-in-components
    2018-01-23T21:40:36.818Z - info: Using extension child-templates
    2018-01-23T21:40:37.036Z - info: Using extension text
    2018-01-23T21:40:37.037Z - info: Using extension licensing
    2018-01-23T21:40:37.548Z - info: Using extension phantom-pdf
    2018-01-23T21:40:37.766Z - info: Using extension data
    2018-01-23T21:40:37.963Z - info: Using extension reports
    2018-01-23T21:40:38.141Z - info: Using extension resources
    2018-01-23T21:40:38.236Z - info: Using extension designer
    2018-01-23T21:40:38.888Z - info: Using extension studio
    2018-01-23T21:40:39.509Z - info: Using extension scripts
    2018-01-23T21:40:39.596Z - info: Using extension scheduling
    2018-01-23T21:40:39.661Z - info: Using extension assets
    2018-01-23T21:40:39.915Z - info: Using extension xlsx
    2018-01-23T21:40:40.930Z - info: Using extension sample-template
    2018-01-23T21:40:41.193Z - debug: Creating samples is disabled
    2018-01-23T21:40:41.193Z - info: Using extension public-templates
    2018-01-23T21:40:41.330Z - debug: Extension public-templates was disabled
    2018-01-23T21:40:41.571Z - info: Creating memory store
    2018-01-23T21:40:41.627Z - info: Creating default express app.
    2018-01-23T21:40:46.667Z - info: jsreport server successfully started on http port: 4000
    2018-01-23T21:40:46.692Z - debug: Registering component Text for designer
    2018-01-23T21:40:46.706Z - debug: Registering component Image for designer
    2018-01-23T21:40:46.713Z - debug: Registering component Table for designer
    2018-01-23T21:40:46.713Z - debug: Registering component Products-Map for designer
    2018-01-23T21:40:46.713Z - debug: Registering component Pie-Chart for designer
    2018-01-23T21:40:46.713Z - debug: Registering component QR for designer
    2018-01-23T21:40:46.713Z - debug: Registering component User-Info for designer
    2018-01-23T21:40:46.714Z - info: Verifying license key free
    2018-01-23T21:40:46.717Z - info: Using free license
    2018-01-23T21:40:46.819Z - info: reporter initialized
    ```

  • administrators

    and here are the full logs when a jsreport server starts with an error (you can see that there is an error in the logs)

    2018-01-23T21:46:55.438Z - info: Initializing jsreport@1.7.0 in development mode using configuration file dev.config.json
    2018-01-23T21:46:55.442Z - info: Searching for available extensions in /Volumes/DATA/workspace/jsreport-quick-test/
    2018-01-23T21:46:55.445Z - info: Extensions location cache contains up to date information, skipping crawling in /Volumes/DATA/workspace/jsreport-quick-test/node_modules/
    2018-01-23T21:46:55.450Z - info: Found 39 extensions
    2018-01-23T21:46:55.456Z - debug: Writing extension locations cache to /var/folders/0d/wh3hsmm506d5fws_8x_dsj0c0000gn/T/jsreport-temp/extensions/locations.json
    2018-01-23T21:46:55.457Z - debug: Discovered 39 extensions
    2018-01-23T21:46:55.458Z - info: Using extension import-export
    2018-01-23T21:46:55.586Z - info: Using extension test
    2018-01-23T21:46:55.587Z - info: Using extension templates
    2018-01-23T21:46:55.590Z - info: Using extension azure-storage
    2018-01-23T21:46:55.670Z - info: Using extension tags
    2018-01-23T21:46:55.671Z - info: Using extension postgres-store
    2018-01-23T21:46:55.776Z - info: Using extension mssql-store
    2018-01-23T21:46:55.781Z - info: Using extension mongodb-store
    2018-01-23T21:46:55.845Z - info: Using extension cli
    2018-01-23T21:46:55.845Z - info: Using extension jsrender
    2018-01-23T21:46:55.846Z - error: Error when loading extension Error: test error
    Error: test error
        at module.exports (/Volumes/DATA/workspace/jsreport-quick-test/node_modules/jsreport-jsrender/lib/jsrender.js:6:9)
        at /Volumes/DATA/workspace/jsreport-quick-test/node_modules/jsreport-core/lib/extensions/extensionsManager.js:122:72
        at tryCatcher (/Volumes/DATA/workspace/jsreport-quick-test/node_modules/bluebird/js/release/util.js:16:23)
        at Promise._settlePromiseFromHandler (/Volumes/DATA/workspace/jsreport-quick-test/node_modules/bluebird/js/release/promise.js:512:31)
        at Promise._settlePromise (/Volumes/DATA/workspace/jsreport-quick-test/node_modules/bluebird/js/release/promise.js:569:18)
        at Promise._settlePromiseCtx (/Volumes/DATA/workspace/jsreport-quick-test/node_modules/bluebird/js/release/promise.js:606:10)
        at Async._drainQueue (/Volumes/DATA/workspace/jsreport-quick-test/node_modules/bluebird/js/release/async.js:138:12)
        at Async._drainQueues (/Volumes/DATA/workspace/jsreport-quick-test/node_modules/bluebird/js/release/async.js:143:10)
        at Immediate.Async.drainQueues (/Volumes/DATA/workspace/jsreport-quick-test/node_modules/bluebird/js/release/async.js:17:14)
        at runCallback (timers.js:785:20)
        at tryOnImmediate (timers.js:747:5)
        at processImmediate [as _immediateCallback] (timers.js:718:5)
    2018-01-23T21:46:55.846Z - info: Using extension debug
    2018-01-23T21:46:55.847Z - debug: Extension authentication is disabled, skipping
    2018-01-23T21:46:55.847Z - info: Using extension express
    2018-01-23T21:46:55.894Z - info: Using extension fop-pdf
    2018-01-23T21:46:55.897Z - info: Using extension handlebars
    2018-01-23T21:46:55.898Z - info: Using extension reports
    2018-01-23T21:46:55.899Z - info: Using extension fs-store
    2018-01-23T21:46:56.012Z - info: Using extension html-to-xlsx
    2018-01-23T21:46:56.041Z - info: Using extension images
    2018-01-23T21:46:56.043Z - info: Using extension electron-pdf
    2018-01-23T21:46:56.090Z - info: Using extension data
    2018-01-23T21:46:56.091Z - debug: Extension licensing is disabled, skipping
    2018-01-23T21:46:56.091Z - info: Using extension chrome-pdf
    2018-01-23T21:46:56.110Z - info: Using extension child-templates
    2018-01-23T21:46:56.111Z - info: Using extension phantom-pdf
    (node:8974) [DEP0022] DeprecationWarning: os.tmpDir() is deprecated. Use os.tmpdir() instead.
    2018-01-23T21:46:56.135Z - info: Using extension browser-client
    2018-01-23T21:46:56.137Z - info: Using extension wkhtmltopdf
    2018-01-23T21:46:56.164Z - info: Using extension html-embedded-in-docx
    2018-01-23T21:46:56.291Z - info: Using extension resources
    2018-01-23T21:46:56.292Z - info: Using extension text
    2018-01-23T21:46:56.293Z - info: Using extension authorization
    2018-01-23T21:46:56.293Z - debug: Extension authorization was disabled
    2018-01-23T21:46:56.293Z - info: Using extension base
    2018-01-23T21:46:56.294Z - info: Using extension studio
    2018-01-23T21:46:56.325Z - info: Using extension scripts
    2018-01-23T21:46:56.326Z - info: Using extension scheduling
    2018-01-23T21:46:56.347Z - info: Using extension xlsx
    2018-01-23T21:46:56.397Z - info: Using extension assets
    2018-01-23T21:46:56.401Z - info: Using extension sample-template
    2018-01-23T21:46:56.401Z - info: Using extension public-templates
    2018-01-23T21:46:56.403Z - debug: Extension public-templates was disabled
    2018-01-23T21:46:56.404Z - info: Initializing fs storage at /Volumes/DATA/workspace/jsreport-quick-test/data
    2018-01-23T21:46:57.142Z - info: Creating default express app.
    2018-01-23T21:46:57.166Z - info: jsreport server successfully started on http port: 5488
    2018-01-23T21:46:57.171Z - info: reporter initialized
    


  • Hi,
    I am sorry about the confusion.
    From the console: it just stucks at 2018-01-23T21:45:31.108Z - info: Extensions location cache /tmp/jsreport/core/locations.json contains older information, crawling

    the repeated ones until ... , crawling I got from the log file /logs/reporter1.log. This log file is > 6MB so I wonder if I can send it to you by email?


  • administrators

    hmm 6mb of logs probably won't help me because there will be a lot of information in there. can you copy the current reporter1.log somewhere (maybe i will ask you to send me that file later) just to save that information and then just clear all the content inside that file to have clear logs?

    also, can you try to delete the /tmp/jsreport/core/locations.json file? and then try to start server again.



  • It is weird. I have deleted /tmp/jsreport/core/locations.json for serveral times but still can not start.

    ~ > jsreport start
    2018-01-23T22:06:46.263Z - info: Initializing jsreport@1.9.2 in development mode using configuration file: jsreport.config.json
    2018-01-23T22:06:46.265Z - info: Setting process based strategy for rendering. Please visit http://jsreport.net/learn/configuration for information how to get more performance.
    2018-01-23T22:06:46.266Z - info: Searching for available extensions in /home/user/
    2018-01-23T22:06:46.268Z - info: Extensions location cache not found, crawling directories
    ^[[A^C
    ~ > jsreport start
    2018-01-23T22:07:35.747Z - info: Initializing jsreport@1.9.2 in development mode using configuration file: jsreport.config.json
    2018-01-23T22:07:35.748Z - info: Setting process based strategy for rendering. Please visit http://jsreport.net/learn/configuration for information how to get more performance.
    2018-01-23T22:07:35.750Z - info: Searching for available extensions in /home/user/
    2018-01-23T22:07:35.751Z - info: Extensions location cache not found, crawling directories

    I deleted all log files then the newly one is empty no matter how many times I try to start the server.


  • administrators

    when starting the server, in which part the error happens? are you waiting until the error happen? or are you just killing the process when getting stuck at info: Extensions location cache not found, crawling directories log?



  • Just because it seems stuck at ..crawling without any further progress for some minutes so I killed the process. Now I let one console going on. What is the maximum crawling time? My PC is fast CPU and using SSD.


  • administrators

    ok, i just needed some confirmation that you were killing the process..

    according to logs it seems that your app is located at /home/user/ or /home/trung/, those seems os level home directories so by nature those directories can contain a lot of files and since jsreport do some crawling to find installed extensions doing that search at a home directory is super intensitive. can you please move your project to /home/user/myjsreportproject and try again? doing that will make the crawling of directories a lot more faster because jsreport won't look at the root level of /home/user



  • Do you mean to remove jsreport from the root dir level then install it again to a sub folder /home/user/myjsreportproject ?
    Do I need to move the /data folder into /home/user/myjsreportproject then re-install the server there?


  • administrators

    Do you mean to remove jsreport from the root dir level then install it again to a sub folder /home/user/myjsreportproject ?

    yes

    Do I need to move the /data folder into /home/user/myjsreportproject then re-install the server there?

    yes, move all your files at /data (because there is where there are all of your templates, etc), and re-install in the new place



  • Now, installed in the new folder then I still got error:

    myjsreport > jsreport start
    2018-01-23T22:38:40.434Z - info: Initializing jsreport@1.9.2 in development mode using configuration file: jsreport.config.json
    2018-01-23T22:38:40.436Z - info: Setting process based strategy for rendering. Please visit http://jsreport.net/learn/configuration for information how to get more performance.
    2018-01-23T22:38:40.437Z - info: Searching for available extensions in /home/trung/myjsreport/
    2018-01-23T22:38:40.439Z - info: Extensions location cache not found, crawling directories
    2018-01-23T22:38:40.550Z - info: Found 30 extensions
    2018-01-23T22:38:40.556Z - debug: Writing extension locations cache to /tmp/jsreport/core/locations.json
    2018-01-23T22:38:40.557Z - debug: Discovered 30 extensions
    2018-01-23T22:38:40.557Z - info: Using extension import-export
    2018-01-23T22:38:40.645Z - info: Using extension tags
    2018-01-23T22:38:40.647Z - info: Using extension templates
    2018-01-23T22:38:40.648Z - info: Using extension jsrender
    2018-01-23T22:38:40.649Z - debug: Extension authentication is disabled, skipping
    2018-01-23T22:38:40.649Z - info: Using extension cli
    2018-01-23T22:38:40.649Z - info: Using extension handlebars
    2018-01-23T22:38:40.650Z - info: Using extension debug
    2018-01-23T22:38:40.650Z - info: Using extension express
    2018-01-23T22:38:40.688Z - info: Using extension fop-pdf
    2018-01-23T22:38:40.691Z - info: Using extension phantom-pdf
    2018-01-23T22:38:40.721Z - info: Using extension fs-store
    2018-01-23T22:38:40.814Z - info: Using extension authorization
    2018-01-23T22:38:40.814Z - debug: Extension authorization was disabled
    2018-01-23T22:38:40.814Z - info: Using extension images
    2018-01-23T22:38:40.816Z - info: Using extension child-templates
    2018-01-23T22:38:40.817Z - info: Using extension browser-client
    2018-01-23T22:38:40.817Z - info: Using extension licensing
    2018-01-23T22:38:40.831Z - info: Using extension data
    2018-01-23T22:38:40.832Z - info: Using extension text
    2018-01-23T22:38:40.832Z - info: Using extension reports
    2018-01-23T22:38:40.833Z - info: Using extension resources
    2018-01-23T22:38:40.834Z - info: Using extension base
    2018-01-23T22:38:40.834Z - info: Using extension studio
    2018-01-23T22:38:40.869Z - info: Using extension html-to-xlsx
    2018-01-23T22:38:40.897Z - info: Using extension scripts
    2018-01-23T22:38:40.898Z - info: Using extension assets
    2018-01-23T22:38:40.901Z - info: Using extension scheduling
    2018-01-23T22:38:40.940Z - info: Using extension xlsx
    2018-01-23T22:38:41.010Z - info: Using extension sample-template
    2018-01-23T22:38:41.010Z - info: Using extension public-templates
    2018-01-23T22:38:41.012Z - debug: Extension public-templates was disabled
    2018-01-23T22:38:41.013Z - info: Initializing fs storage at /home/trung/myjsreport/data
    2018-01-23T22:38:41.093Z - error: Failed to load collection settings Error: More than 10% of the data file is corrupt, the wrong beforeDeserialization hook may be used. Cautiously refusing to start NeDB to prevent dataloss
    at Persistence.treatRawData (/home/trung/myjsreport/node_modules/nedb/lib/persistence.js:242:11)
    at /home/trung/myjsreport/node_modules/nedb/lib/persistence.js:281:38
    at FSReqWrap.readFileAfterClose [as oncomplete] (fs.js:511:3)
    2018-01-23T22:38:41.094Z - error: Error occured during reporter init Error: More than 10% of the data file is corrupt, the wrong beforeDeserialization hook may be used. Cautiously refusing to start NeDB to prevent dataloss
    at Persistence.treatRawData (/home/trung/myjsreport/node_modules/nedb/lib/persistence.js:242:11)
    at /home/trung/myjsreport/node_modules/nedb/lib/persistence.js:281:38
    at FSReqWrap.readFileAfterClose [as oncomplete] (fs.js:511:3)
    Error: An error has occurred when trying to initialize jsreport..
    at /home/trung/myjsreport/node_modules/jsreport-cli/lib/instanceHandler.js:31:23
    at tryCatcher (/home/trung/myjsreport/node_modules/jsreport-core/node_modules/bluebird/js/release/util.js:16:23)
    at Promise._settlePromiseFromHandler (/home/trung/myjsreport/node_modules/jsreport-core/node_modules/bluebird/js/release/promise.js:512:31)
    at Promise._settlePromise (/home/trung/myjsreport/node_modules/jsreport-core/node_modules/bluebird/js/release/promise.js:569:18)
    at Promise._settlePromise0 (/home/trung/myjsreport/node_modules/jsreport-core/node_modules/bluebird/js/release/promise.js:614:10)
    at Promise._settlePromises (/home/trung/myjsreport/node_modules/jsreport-core/node_modules/bluebird/js/release/promise.js:689:18)
    at Async._drainQueue (/home/trung/myjsreport/node_modules/jsreport-core/node_modules/bluebird/js/release/async.js:133:16)
    at Async._drainQueues (/home/trung/myjsreport/node_modules/jsreport-core/node_modules/bluebird/js/release/async.js:143:10)
    at Immediate.Async.drainQueues (/home/trung/myjsreport/node_modules/jsreport-core/node_modules/bluebird/js/release/async.js:17:14)
    at runCallback (timers.js:789:20)
    at tryOnImmediate (timers.js:751:5)
    at processImmediate [as _immediateCallback] (timers.js:722:5) {"originalError":{"cause":{},"isOperational":true}}
    (Original) Error: More than 10% of the data file is corrupt, the wrong beforeDeserialization hook may be used. Cautiously refusing to start NeDB to prevent dataloss
    at Persistence.treatRawData (/home/trung/myjsreport/node_modules/nedb/lib/persistence.js:242:11)
    at /home/trung/myjsreport/node_modules/nedb/lib/persistence.js:281:38
    at FSReqWrap.readFileAfterClose [as oncomplete] (fs.js:511:3) {"cause":{},"isOperational":true}



  • As with previous resolution when I got error: error: Failed to load collection settings Error: More than 10% of the data file is corrupt, .I backed up /data/settings file then delete it then the server can start. However, I got another error when try to Run the report within localhost:5488

    Error occured - Error during rendering report: Unsupported module in scripts: http. To enable require on particular module, you need to update the configuration as {"scripts": { "allowedModules": ["http"] } } ... Alternatively you can also set "*" to allowedModules to enable everything
    Stak - /home/trung/myjsreport/node_modules/jsreport-scripts/lib/scriptEvalChild.js:44
    throw new Error('Unsupported module in scripts: ' + moduleName + '. To enable require on particular module, you need to update the configuration as ' +
    ^

    Error: Unsupported module in scripts: http. To enable require on particular module, you need to update the configuration as {"scripts": { "allowedModules": ["http"] } } ... Alternatively you can also set "*" to allowedModules to enable everything
    at _require (/home/trung/myjsreport/node_modules/jsreport-scripts/lib/scriptEvalChild.js:44:11)
    at evalmachine.<anonymous>:2:12
    at ContextifyScript.Script.runInContext (vm.js:59:29)
    at ContextifyScript.Script.runInNewContext (vm.js:65:15)
    at Object.runInNewContext (vm.js:135:38)
    at module.exports (/home/trung/myjsreport/node_modules/jsreport-scripts/lib/scriptEvalChild.js:123:6)
    at process.<anonymous> (/home/trung/myjsreport/node_modules/script-manager/lib/worker-processes.js:48:36)
    at emitTwo (events.js:126:13)
    at process.emit (events.js:214:7)
    at emit (internal/child_process.js:772:12)


  • administrators

    As with previous resolution when I got error: error: Failed to load collection settings Error: More than 10% of the data file is corrupt, .I backed up /data/settings file then delete it then the server can start.

    yes, i was about to recommend you to do that.

    However, I got another error when try to Run the report within localhost:5488
    Error occured - Error during rendering report: Unsupported module in scripts: http. To enable require on particular module, you need to update the configuration as {"scripts": { "allowedModules": ["http"] } } ... Alternatively you can also set "*" to allowedModules to enable everything
    Stak - /home/trung/myjsreport/node_modules/jsreport-scripts/lib/scriptEvalChild.js:44
    throw new Error('Unsupported module in scripts: ' + moduleName + '. To enable require on particular module, you need to update the configuration as ' +

    yes, as the error says, you need to update your configuration file to have something like this:

    {
    // ...other config..
    "tasks": {
    //...other config..
    allowedModules: '*'
    //...other config..
    }
    ...other config
    }
    

  • administrators

    sorry the right config is this:

    {
    // ...other config..
    "scripts": {
    //...other config..
    "allowedModules": "*"
    //...other config..
    }
    //...other config
    }
    

    just ignore the ...other config comments, i just place them to represent that you can place other config there too.



  • Yey, now it works again. Thanks a lot for your help.


  • administrators

    for the record, can you please send me the corrupted /data/settings file at bjrmatos@gmail.com? i would like to check what part if corrupted and if we can do anything about it.



  • Ok sure. The file was sent. Thanks again. Hopefull It would not happen again. This time we are not lucky during the demo to our customer.


  • administrators

    Thanks


Log in to reply
 

Looks like your connection to jsreport forum was lost, please wait while we try to reconnect.