JSCAD User Group
    • Tags
    • Popular
    • Users
    • Groups
    • Register
    • Login

    debug jscode cli with vscode

    Scheduled Pinned Locked Moved General Discussions
    5 Posts 2 Posters 1.3k Views 1 Watching
    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 HahnM Offline
      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 HahnM 1 Reply Last reply Reply Quote 0
      • Mark HahnM Offline
        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"

        z3devZ Mark HahnM 2 Replies Last reply Reply Quote 1
        • z3devZ Online
          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 HahnM Offline
            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.

            z3devZ 1 Reply Last reply Reply Quote 2
            • z3devZ Online
              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

              Hello! It looks like you're interested in this conversation, but you don't have an account yet.

              Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

              With your input, this post could be even better 💗

              Register Login
              • First post
                Last post
              Powered by NodeBB | Contributors