webpack/webpack-cli

webpack info: misdetects shimmed, upgraded npm

tony opened this issue · 1 comments

tony commented

This may apply to nvm too - if that is true, this definitely isn't an edgecase then. A lot of us rely on version managers and webpack info should give us the true npm we use.

Describe the bug

webpack info isn't detecting the npm bin and version of my environment / shell.

This isn't managed by PATH, it's managed by shim:

❯ which npm
/home/t/.config/.asdf/shims/npm

What is the current behavior?

webpack-cli: 4.7.0

webpack info returns:

npm: 6.14.13 - ~/.config/.asdf/installs/nodejs/14.17.0/bin/npm

I expect this:

npm: 7.18.1 - ~/.config/.asdf/installs/nodejs/14.17.0/.npm/bin/npm

To Reproduce

.nvmrc: 14.17.0 (system node v12.20.1)

node 14 has npm 6 by default

Expected behavior

Screenshots

❯ npm --version
7.18.1
❯ which npm
/home/t/.config/.asdf/shims/npm
❯ asdf which npm
/home/t/.config/.asdf/installs/nodejs/14.17.0/.npm/bin/npm
❯ asdf which node
/home/t/.config/.asdf/installs/nodejs/14.17.0/bin/node

webpack info

  System:
    OS: Linux 4.19 Ubuntu 20.04.2 LTS (Focal Fossa)
    ...
  Binaries:
    Node: 14.17.0 - ~/.config/.asdf/installs/nodejs/14.17.0/bin/node
    Yarn: 1.22.10 - ~/.yarn/bin/yarn
    npm: 6.14.13 - ~/.config/.asdf/installs/nodejs/14.17.0/bin/npm
  Browsers:
    Chrome: 91.0.4472.114
  Packages:
    copy-webpack-plugin: ^7.0.0 => 7.0.0
    css-minimizer-webpack-plugin: ^3.0.1 => 3.0.1
    fork-ts-checker-webpack-plugin: ^6.1.0 => 6.1.0
    html-webpack-plugin: ^4.5.1 => 4.5.1
    speed-measure-webpack-plugin: ^1.5.0 => 1.5.0
    webpack: ^5.37.1 => 5.37.1
    webpack-bundle-analyzer: ^4.3.0 => 4.3.0
    webpack-cli: ^4.7.0 => 4.7.0
    webpack-dev-server: ^3.11.1 => 3.11.1
    webpack-merge: ^5.7.3 => 5.7.

Additional context

i use asdf + asdf-nodejs

This can cause issue downstream in shells relying on version managers and locally upgraded npms

We use this module to get system info - https://github.com/tabrindle/envinfo, here code https://github.com/webpack/webpack-cli/blob/master/packages/info/src/index.ts#L80, no magic on our side, please open an issue in their repo, thanks