npm Community Forum (Archive)

The npm community forum has been discontinued.

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

npm unpublish does not honor publishConfig registry

What I Wanted to Do

Tried to unpublish a package which has its packageConfig.registry set.

What Happened Instead

This packageConfig.registry setting is ignored when unpublishing, leading to a confusing error message (npm ERR! 400 Bad Request). The behavior is inconsistent between publish and unpublish.

Reproduction Steps

# set a default scope to another registry
npm config set registry --global
# create an npm module
mkdir test
cd test
npm init
edit your package.json and add `"packageConfig": { "registry": "" }`
npm publish
# within 24 hours
npm unpublish thepackagename --force


Platform Info

I tested with npm 6.5, 6.4, 6.3, 6.2, 5.10

$ npm --versions
{ '@paypaldev/pkg3': '1.0.0',
  npm: '6.5.0',
  ares: '1.10.1-DEV',
  cldr: '32.0',
  http_parser: '2.8.0',
  icu: '60.1',
  modules: '57',
  napi: '3',
  nghttp2: '1.32.0',
  node: '8.12.0',
  openssl: '1.0.2p',
  tz: '2017c',
  unicode: '10.0',
  uv: '1.19.2',
  v8: '6.2.414.66',
  zlib: '1.2.11' }
$ node -p process.platform

My first impression is this is probably expected behaviour, but see if this makes sense.

When you use unpublish, npm refers to the default registry you have set: The package does not exist there so the command fails.

Publish is consulting a package.json file on disk for details.
Unpublish is modifying a registry using a package name.
I do not think they are symmetrical?