Error when run "jsreport start"



  • Hi everyone, I've been struggling with this issue for 4 days now.

    I used jsreport in a separate project and am migrating to a monorepo.

    The problem is that when I leave jsreport outside the monorepo and install the dependencies, the node_modules folder is created inside the jsreport folder, and everything works normally.

    But in monorepo, the node_modules is in the monorepo root folder and not inside the jsreport folder. And with that, I'm getting the following error when I run jsreport start inside de folder and I can't solve it.

    An error ocurred while trying to execute "start" command (2). Couldn't find a jsreport installation necessary to continue with the execution of the command, make sure to install jsreport first. (1). 
    caused by error (2)
    

    But if I run jsreport init or config command it works correctly !

    Thank you very much for any help!


  • administrators

    hi! we develop jsreport in a monorepo (with yarn), so far it works the jsreport start works good there. what tool are you using for the monorepo? yarn, pnpm, npm? what is your package.json content? it will be even better if you can create just a demo github repository with the monorepo and jsreport there, so we can quickly test and verify what we can do or change to support the start in this case.



  • Hi I'm using npm. In the monorepo package.json, I have the following configuration:

    "workspaces": [ "packages/*", "apps/*" ]

    The folder with jsreport and other services is inside the apps folder.

    And the jsreport I have this package.json:

    {
      "name": "reports",
      "version": "1.0.0",
      "main": "server.js",
      "dependencies": {
        "@jsreport/jsreport-chrome-pdf": "^3.2.0",
        "@jsreport/jsreport-cli": "^3.2.1",
        "custom-extension": "file:dependencies/jsreport-nunjucks",
        "diff": "^5.1.0",
        "jsreport": "^3.7.1",
        "moment-timezone": "^0.5.37",
        "puppeteer": "^14.4.1"
      },
      "scripts": {
        "start": "jsreport start"
      },
      "author": "",
      "license": "ISC"
    }
    

    Thanks for the help!


  • administrators

    i can verify that it is not working on the monorepo, it is basically because the way we search the jsreport dependency.

    a workaround is to set this env var to cli_instance_lookup_fallback=enabled, you can update your start script in app/reports to cli_instance_lookup_fallback=enabled jsreport start, after it will work, we will investigate if we enabled this by default or not in this issue



  • Setting env var to cli_instance_lookup_fallback=enabled happens the same thing as when I run server.js directly. The server starts, but without any templates.

    I tried to import the templates and it works, but as soon as I stop the server and run it again, it loses all!

    0_1666963839438_upload-ec307900-3832-4d82-8ca2-4fbf060834c6


  • administrators

    you probably now need to change the configFile https://jsreport.net/learn/configuration#directories
    where is your jsreport.config.json file? at the reports package? or at the monorepo root level? if it is at the reports package i believe you can update your start script to this cli_instance_lookup_fallback=enabled jsreport start --configFile=./apps/reports/jsreport.config.json



  • This post is deleted!


  • Hi, it worked. But it is creating the data folder in the monorepo root and not reading the existing one I have inside the report folder.
    I tried to use some options in the documentation to specify the report folder, but it didn't work!


  • administrators

    i see, the option for data directory is document here in fs store options. so you can use this command to make it work cli_instance_lookup_fallback=enabled jsreport start --configFile=./apps/reports/jsreport.config.json --extensions.fsStore.dataDirectory=./apps/reports/data



  • It's working now. Appreciate your help. Thanks !!


Log in to reply
 

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