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

[BUG] CLI command dont fail when provided with invalid options #6638

Open
2 tasks done
BackEndTea opened this issue Jul 10, 2023 · 2 comments
Open
2 tasks done

[BUG] CLI command dont fail when provided with invalid options #6638

BackEndTea opened this issue Jul 10, 2023 · 2 comments
Labels
Bug thing that needs fixing Needs Triage needs review for next steps Release 9.x work is associated with a specific npm 9 release

Comments

@BackEndTea
Copy link

BackEndTea commented Jul 10, 2023

Is there an existing issue for this?

  • I have searched the existing issues

This issue exists in the latest npm version

  • I am using the latest npm

Current Behavior

When running npm explain --omit=dev for example, you get no error that the --omit isn't a valid option for this command.

This can cause a lot of frustrations when you get unexpected results.

Expected Behavior

I would expect npm to error with a non 0 exit code, before running the logic of the command itself, telling me i made an error and used an unsuported option.

Steps To Reproduce

  1. In any evironment
  2. With any config
  3. Run any npm command with invalid option
  4. See no errors

Environment

  • npm: 9.3.1
  • Node.js: v18.14.0
  • OS Name: Any
  • System Model Name: Any
  • npm config:
; "user" config from /root/.npmrc

//registry.npmjs.org/:_authToken = (protected) 

; "project" config from /home/node/app/src/frontend/.npmrc

engine-strict = true 

; node bin location = /usr/local/bin/node
; node version = v18.14.0
; npm local prefix = /home/node/app/src/frontend
; npm version = 9.3.1
; cwd = /home/node/app/src/frontend
; HOME = /root
; Run `npm config ls -l` to show all defaults.
@BackEndTea BackEndTea added Bug thing that needs fixing Needs Triage needs review for next steps Release 9.x work is associated with a specific npm 9 release labels Jul 10, 2023
@shadowspawn
Copy link
Contributor

shadowspawn commented Jul 16, 2023

This is a "feature" which causes much confusion. Any unknown options are consumed by npm and turned into environment variables. I think the intention is to easily make custom options available to scripts, but the resulting lack of error checking is a high penalty to pay.

To demonstrate, here I have added a run-script named env which calls env.

% npm run env --omit=dev | grep omit
npm_config_omit=dev

@l0b0
Copy link

l0b0 commented Sep 21, 2023

I just spent a good while investigating a CDK issue which turned out to be this issue. Very frustrating.

l0b0 added a commit to linz/hydro-aws-infrastructure that referenced this issue Sep 25, 2023
`npm run` by default treats all parameters as its own, and *ignores*
unknown parameters <npm/cli#6638>.
github-merge-queue bot pushed a commit to linz/hydro-aws-infrastructure that referenced this issue Sep 25, 2023
`npm run` by default treats all parameters as its own, and *ignores*
unknown parameters <npm/cli#6638>.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug thing that needs fixing Needs Triage needs review for next steps Release 9.x work is associated with a specific npm 9 release
Projects
None yet
Development

No branches or pull requests

3 participants