Skip to content

[BUG] npm view --registry option not respected #7904

Closed
@boutell

Description

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

If @mynamespace/my-tool exists in regular npm, but my root .npmrc looks like this:

//registry.npmjs.org/:_authToken=abcdef
//npm.portal.mycompany.dev/:_authToken=ghijkl
@mynamespace:registry=https://npm.portal.apos.dev

This command will yield output from npm.portal.mycompany.dev, even though registry.npmjs.org was explicitly specified by a command line option:

npm view @mynamespace/my-tool --json --registry=https://registry.npmjs.org

In other words, --registry is silently ignored by npm view.

There is no package-lock.json file in play here.

Expected Behavior

Output from the main npm registry, because --registry was expressly used to request that.

Steps To Reproduce

See above. I suggest that you publish clearly distinct version numbers to the two registries to simplify the test.

Environment

  • npm: 10.9.0 (others tried)
  • Node.js: 18.20.4
  • OS Name: MacOS
  • System Model Name:
  • npm config:
; copy and paste output from `npm config ls` here
; "user" config from /Users/boutell/.npmrc

@apostrophecms-pro:registry = "https://npm.portal.apos.dev"
//npm.portal.apos.dev/:_authToken = (protected)
//registry.npmjs.org/:_authToken = (protected)

; node bin location = /Users/boutell/.nvm/versions/node/v18.20.4/bin/node
; node version = v18.20.4
; npm local prefix = /opt/ops-tools
; npm version = 10.9.0
; cwd = /opt/ops-tools
; HOME = /Users/boutell
; Run `npm config ls -l` to show all defaults.

Metadata

Assignees

No one assigned

    Labels

    Bugthing that needs fixingNeeds Triageneeds review for next steps

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions