JSCAD User Group

    • Register
    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups

    debug jscode cli with vscode

    General Discussions
    2
    5
    629
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • Mark Hahn
      Mark Hahn last edited by

      I created a project based on the example cli at Install the CLI as Part of a Project. My jscad code works and creates the same stl as using the openjscad.xyz web page.

      I'm having problems with vectorChar and I'd like to use vscode to step through the jscad cli code and debug it. I need to do this because the vectorChar code in the repo is very simple but I'm getting crazy results.

      I tried this launch.json ...

            "type": "pwa-node",
            "request": "launch",
            "name": "Launch Program",
            "skipFiles": [
              "<node_internals>/**"
            ],
            "program": "jscad"
      

      I pretty much knew it wouldn't work because jscode doesn't exist in my app's folder. Can anyone tell me what I should put in for "program" to run the jscad cli in debug mode?

      Mark Hahn 1 Reply Last reply Reply Quote 0
      • z3dev
        z3dev @Mark Hahn last edited by

        @mark-hahn super thanks!

        There’s still a little wizardry going on here. But I’ll try this with VSCODE, and then ask a few more questions.

        1 Reply Last reply Reply Quote 0
        • Mark Hahn
          Mark Hahn @Mark Hahn last edited by

          I should add the steps needed to use vscode to debug.

          1. Clone the jscad cli repo
          2. Do an npm install
          3. Create a standard launch profile for node.

          Here is my launch.json file ...

           "version": "0.2.0",
            "configurations": [
          
              {
                "type": "pwa-node",
                "request": "launch",
                "name": "Launch Program",
                "skipFiles": [
                  "<node_internals>/**"
                ],
                "program": "node_modules/@jscad/cli/cli.js",
                "args": ["text-gen.js"]
              }
            ]
          }
          

          After this I just set a breakpoint in my jscode and launched the debugger. Worked great.

          P.S. If anyone is curious I was able to fix my vectorChar problem. It was in my code but I was only able to find my problem by using the debugger.

          z3dev 1 Reply Last reply Reply Quote 2
          • z3dev
            z3dev @Mark Hahn last edited by

            @mark-hahn Super!

            We often get asked how to use JSCAD inside VSCODE, so please let use know how to setup a project and debug. It would be a HUGE plus for JSCAD to be able to debug designs.

            1 Reply Last reply Reply Quote 0
            • Mark Hahn
              Mark Hahn @Mark Hahn last edited by

              I found the answer to my problem right after posting this. I tried forever to figure this out before posting. This seems to happen to me a lot.

              For lurkers: The "program" option in the launch file should be "node_modules/@jscad/cli/cli.js"

              z3dev Mark Hahn 2 Replies Last reply Reply Quote 1
              • First post
                Last post
              Powered by NodeBB | Contributors