Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

launch arbitrary program from launch.json #94698

Closed
xenoterracide opened this issue Apr 8, 2020 · 2 comments
Closed

launch arbitrary program from launch.json #94698

xenoterracide opened this issue Apr 8, 2020 · 2 comments

Comments

@xenoterracide
Copy link

Goal: run npx program so that we don't have to know the absolute paath inside of ${workspace}/node_modules problem: there is no way to know where npx is installed`

solution 1: add some local file (that can be ignored), that allows variables to be set for launch.json, then you could easily set ${usrLocal}/npx

solution 2: allow executing env or which or even just searching $PATH

solution 3: specifically add an option to node that is autodetected, ${npx} program

solution 1 is probably the most flexible, and most secure

@IllusionMH
Copy link
Contributor

IllusionMH commented Apr 8, 2020

I think it's already possible similar to debugging npm scripts. Starting from default config Node.js: Launch via NPM and then using "runtimeExecutable": "npx" and "runtimeArgs": ["program"]

However it might take a bit extra to pass debug argument to node (and requires npx 9.1.0+) See zkat/npx#68

So most likely it should be

{
    "type": "node",
    "name": "Launch via npx",
    "port": 9449,
    "request": "launch",
    "runtimeArgs": [
        "--node-arg=--inspect-brk=9449",
        "program"
    ],
    "runtimeExecutable": "npx",
    "outputCapture": "std"
}

(unable to test debugging because my npx version doesn't support this flag, but it downloads and correctly uses typescript to output version or run --init with "runtimeArgs": ["typescript", "--init"])

@xenoterracide
Copy link
Author

I'm not sure if in some cases the --inspect-brk is needed, but that caused it to blow up for me (oh maybe it's because I forgot "port"). this however worked just fine

    "runtimeArgs": [
        "mocha"
      ],
      "outputCapture": "std",
      "runtimeExecutable": "npx",
      "args": [

thanks. I guess I'll close this, unless it should be in an example doc somewhere, then feel free to reopen.

@github-actions github-actions bot locked and limited conversation to collaborators May 23, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants