Skip to content

[BUG] npm publish should require -f if @scope in npmrc differs from publishConfig #4034

@EvanCarroll

Description

@EvanCarroll

Is there an existing issue for this?

  • I have searched the existing issues

This issue exists in the latest npm version

  • I am using the latest npm

Current Behavior

npm publish is not clear about where it's publishing too.

I have a repository that I pulled down with a clone. My local ~/.npmrc file has,

@acme:registry=https://verdaccio-alpha.dev.acme.net/verdaccio/
//verdaccio-alpha.dev.acme.net/verdaccio/:_authToken="TOKEN"

If I run npm publish where does the repository get pushed? From the location in npmrc which hosts the scope? Nope.

It gets published to production because there is a publishConfig entry in the package.json

  "publishConfig": {
    "registry": "https://verdaccio.dev.acme.net/verdaccio/"
  },

This is not what I would expect. And I don't think having two sources for truth on a command like npm publish is a good idea.

Perhaps if the publishConfig entry isn't the same as the scope, we can require --force?

In our case we were setting up a new development box for verdaccio. I thought changing the npmrc would be sufficient but I will also need to scrub all of the publishConfig

Expected Behavior

I would expect it to require -f as the assumption that I was aware publishConfig was set is not sound.

Steps To Reproduce

  1. Create an npmrc file which sets scope
  2. Create a package in scope
  3. Set publishConfig
  4. Observe publishConfig is taken and scope is ignored.

Environment

~/angular-ui # npm --version
8.1.3
~/angular-ui # node --version
v17.0.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    Bugthing that needs fixingNeeds Triageneeds review for next stepsRelease 8.xwork is associated with a specific npm 8 release

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions