-
Notifications
You must be signed in to change notification settings - Fork 240
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
RFC: npm debug
command
#618
Conversation
accepted/0000-debug-command.md
Outdated
1. GIVEN a `bin` property is present in `package.json` | ||
- THEN launch a debug session for the script referred to by the `bin` property using `node --inspect-brk <bin-script> <script-argv>`. END. | ||
- ELSE continue | ||
1. GIVEN a `main` property is present in `package.json` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what about packages with both a bin and a main that want to debug both?
(i realize it's a bad practice now to have both in the same package, but there's lots of older packages that do)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see the following options:
- Keep implict priority and order and execute
bin
. Require a--main
switch to allow for debuggingmain
. - Keep implicit priority but change order and execute
main
. Require a--bin
switch to allow for debuggingbin
. - Consider it to be a conflict and exit with an NPM ERR. Require a
--main
or--bin
argument innpm debug
sargv
Consequences
- would require us to have a
--main
and--bin
argument, since a--bin
argument seems to be necessary for the case of multiplebin
executables, anyways. - would get us around a
--main
argument and just require a--bin
CLI argument. The latter seems to be necessary for the case of multiple executables (update on this, follows) - would ask for an explicit decision from the user.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Update 70c0a01 decides for 1 and would allow users to be explicit about whether to debug main
or bin
.
npm debug --main
npm debug --bin
Given they provided both --bin
and --main
or none at all then --bin
would take precedence:
npm debug
npm debug --main --bin
... executes a packages bin
script if a package.json
has a bin
and a main
script.
I believe that setting |
From a purely technical point of view, yes, it works (similar to how From a usability perspective I consider
Possible Use Cases 1: Authoring an npm package with a CLIInstead of crafting a command-line or
this RFC proposes to provide something by npm out of the box which allows typing
2: Workspace with one or more project packages having a CLIInstead of crafting a command-line or
this RFC proposes to provide something by npm out of the box which allows typing
3: Debugging tools and 3rd-party packages in a
|
For example *node_modules/foo/package.json* ~~~ "bin": { "not-my-pkg-name": "./bin/script.js", "not-my-pkg-name-2": "./bin/script2.js" } ~~~ Proposal: ~~~ npm debug <package> --bin <name> ~~~ as a general syntax. 1. GIVEN there are multiple executables THEN there MUST be a `--bin` key and value in `argv` 2. GIVEN there's only a single `bin` object property THEN a `--bin` in `argv` *MAY* be omitted 3. GIVEN there is a `--bin` in `argv` THEN `<name>` MUST match some name in the `bin` object ELSE EXIT with NPM ERR. So the example above requires ~~~ npm debug foo --bin not-my-pkg-name ~~~ However *node_modules/foo/package.json* ~~~ "bin": { "not-my-pkg-name": "./bin/script.js" } ~~~ or ~~~ { "bin": "./bin/script.js" } ~~~ both allow for ~~~ npm debug foo ~~~
…debug both? Allow for selecting which one to debug with --bin and --main argument. When both arguments are given --bin takes precedence over --main. When none are given fallback priority is the same.
Proposal has not got much support. Closing this for the sake of clean up. Reopen if you do not agree. |
This RFC proposes an
npm debug
command to simplify debugging npm packages.Prior discussions at npm/feedback#585