Webpack-cli: Interesting behavior when using `info` as a value for `--info-verbosity`

Created on 26 Mar 2020  路  9Comments  路  Source: webpack/webpack-cli

The command npx webpack-cli --watch --progress --info-verbosity info executes npx webpack-cli info instead of setting the flag --info-verbosity to info.

Examples to reproduce the issue:

> npx webpack-cli --version --info-verbosity none
npx: installed 204 in 17.126s
3.3.11
=> all good

> npx webpack-cli --version --info-verbosity verbose
npx: installed 204 in 16.779s
3.3.11
=> all good

>npx webpack-cli --version --info-verbosity thisisatest
npx: installed 204 in 21.704s
3.3.11
=> all good

> npx webpack-cli --version --info-verbosity info
npx: installed 204 in 12.299s
The command moved into a separate package: @webpack-cli/info
Would you like to install info? (That will run yarn add -D @webpack-cli/info) (yes/NO) : %
=> tries to install the info package, so it can run `webpack-cli info`!

What is the current behavior?

> npx webpack-cli --version --info-verbosity info
npx: installed 204 in 12.299s
The command moved into a separate package: @webpack-cli/info
Would you like to install info? (That will run yarn add -D @webpack-cli/info) (yes/NO) : %
=> tries to install the info package (or displays the info if already installed)
=> so it actually runs `webpack-cli info` :(

To Reproduce

See above

Expected behavior

> npx webpack-cli --version --info-verbosity info
npx: installed 204 in 12.299s
3.3.11

Please paste the results of webpack-cli info here, and mention other relevant information

> npx webpack-cli --watch --info-verbosity info

undefined

watch is an invalid option

info-verbosity is an invalid option

infoVerbosity is an invalid option

  System:
    OS: macOS 10.15.3
    CPU: (8) x64 Intel(R) Core(TM) i7-4980HQ CPU @ 2.80GHz
    Memory: 512.84 MB / 16.00 GB
  Binaries:
    Node: 12.16.1 - ~/.asdf/installs/nodejs/12.16.1/bin/node
    Yarn: 1.22.4 - ~/.asdf/installs/nodejs/12.16.1/bin/yarn
    npm: 6.14.4 - ~/w/cockpit/node_modules/.bin/npm
  Browsers:
    Chrome: 80.0.3987.149
    Firefox: 71.0
    Safari: 13.0.5
  npmPackages:
    tsconfig-paths-webpack-plugin: ^3.2.0 => 3.2.0
    webpack: ^4.42.1 => 4.42.1
    webpack-bundle-analyzer: ^3.6.1 => 3.6.1
    webpack-cli: ^3.3.11 => 3.3.11
Bug

Most helpful comment

@anshumanv we can't fix it, people should have webpack in deps, anyway I think we can improve DX, for example check that webpack is not installed and answer question about installation, for example:

Looks webpack is not installed, do you want install? [Y,n]

All 9 comments

@lukaselmer could you say the same against beta?

Screenshot from 2020-03-29 14-24-50

@lukaselmer could you say the same against beta?

Screenshot from 2020-03-29 14-24-50

@snitin315: Yes, the issue still persists in the beta release:

> npx [email protected] --version --info-verbosity verbose
npx: installed 91 in 3.508s
4.0.0-beta.8
[...error unrelated to the issue, see screenshot]

> npx [email protected] --version --info-verbosity info
npx: installed 91 in 3.876s
The command moved into a separate package: @webpack-cli/info
Would you like to install info? (That will run yarn add -D @webpack-cli/info) (yes/NO) : 
[...error unrelated to the issue, see screenshot]

> npx webpack-cli --version --info-verbosity verbose
3.3.11

> npx webpack-cli --version --info-verbosity info
The command moved into a separate package: @webpack-cli/info
Would you like to install info? (That will run yarn add -D @webpack-cli/info) (yes/NO) : %                                                                                                                         

image

@snitin315 what happens when you run npx webpack-cli --version --info-verbosity info and npx [email protected] --version --info-verbosity info on your machine?

Thanks for the issue

@lukaselmer Working for me in beta.

Screenshot from 2020-04-02 10-00-37

@snitin315 what happens when you run npx webpack-cli --version --info-verbosity info and npx [email protected] --version --info-verbosity info on your machine?

npx webpack-cli --version --info-verbosity info works fine
npx [email protected] --version --info-verbosity info this installs beta first and works fine.

Screenshot from 2020-04-02 10-05-48

@snitin315 Can you send tests to ensure we don't have that problem?

Sure , on it.

@evilebottnawi, was able to reproduce this on a machine which doesn't have webpack installed, right now we're expecting the user to supply the webpack version of their choice via peerDependencies, and since when run via npx and the user doesn't have webpack installed globally this throws, only solution that I can think of right now is moving it to dependencies, please let me know if there are any alternatives, will fix appropriately.

image

@anshumanv we can't fix it, people should have webpack in deps, anyway I think we can improve DX, for example check that webpack is not installed and answer question about installation, for example:

Looks webpack is not installed, do you want install? [Y,n]
Was this page helpful?
0 / 5 - 0 ratings

Related issues

fokusferit picture fokusferit  路  4Comments

sam-s4s picture sam-s4s  路  5Comments

billyjanitsch picture billyjanitsch  路  3Comments

logo749 picture logo749  路  4Comments

r00nscapenab picture r00nscapenab  路  4Comments