npm Community Forum (Archive)

The npm community forum has been discontinued.

To discuss usage of npm, visit the GitHub Support Community.

npm pack && npm publish doesn't respect `--prefix`

What I Wanted to Do

Use --prefix with npm publish

What Happened Instead

npm publish happened from current directory

Reproduction Steps

git clone https://github.com/Yeti-or/npm-pack-prefix
cd npm-pack-prefix
npm pack --prefix packages/nested

Platform Info

$ npm --versions

{ 'npm-pack-prefix': '1.0.0',
  npm: '6.2.0',
  ares: '1.10.1-DEV',
  cldr: '31.0.1',
  http_parser: '2.7.0',
  icu: '59.1',
  modules: '57',
  nghttp2: '1.25.0',
  node: '8.6.0',
  openssl: '1.0.2l',
  tz: '2017b',
  unicode: '9.0',
  uv: '1.14.1',
  v8: '6.0.287.53',
  zlib: '1.2.11' }

$ node -p process.platform
darwin


I think this is intended behavior but the docs are confusing and your proposed behavior sound good too.


npm pack docs: (emphasis mine)

If no arguments are supplied, then npm packs the current package folder.

While the code just uses the current folder (and npm publish does too).