npm prune does not respect prefix param

What I Wanted to Do

Running npm prune with --prefix gets that prefix ignored.

What Happened Instead

Prefix param is not respected.

Reproduction Steps

    mkdir -p prunetest/app
    cd prunetest/app
    npm init -f
    npm install --save express
    npm install --save-dev react
    rm -rf node_modules/
    cd ..
    npm --prefix app/ install  # this works fine
    npm --prefix app/ prune --production # this one doesn't work

    npm WARN enoent ENOENT: no such file or directory, open '/home/ubuntu/prunetest/package.json'
    npm WARN . No description
    npm WARN . No repository field.
    npm WARN . No README data
    npm WARN . No license field.

Details

Bug has been introduced probably with version v4.1.0 of npm - 981ce6395e7892dde2591b44e484e191f8625431

Platform Info

$ npm --versions
{ npm: '6.9.0',
  ares: '1.15.0',
  brotli: '1.0.7',
  cldr: '35.1',
  http_parser: '2.8.0',
  icu: '64.2',
  modules: '64',
  napi: '4',
  nghttp2: '1.34.0',
  node: '10.16.0',
  openssl: '1.1.1b',
  tz: '2019a',
  unicode: '12.1',
  uv: '1.28.0',
  v8: '6.8.275.32-node.52',
  zlib: '1.2.11' }
$ node -p process.platform
linux

Any chance you’ll look into to?

I reproduced the issue using npm v6.10.2 on Mac.

Good hunting finding a possible source change introducing the issue.

It seems like there is an easy work-around, changing directory to prunetest/app and running purge? (Still a bug, just less urgent to fix when there is a work-around.)

(One way bugs get given weight is by voting, and I assume you can vote for your own bug.)