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 https://some.other.com/ --global
# create an npm module
mkdir test
cd test
npm init
edit your package.json and add `"packageConfig": { "registry": "https://registry.npmjs.org" }`
npm publish
# within 24 hours
npm unpublish thepackagename --force

Details

Platform Info

osx
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
darwin

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: https://some.other.com. 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?

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.