npm / cli

the package manager for JavaScript
https://docs.npmjs.com/cli/
Other
8.49k stars 3.17k forks source link

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

Open boutell opened 4 days ago

boutell commented 4 days ago

Is there an existing issue for this?

This issue exists in the latest npm version

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

@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.

boutell commented 4 days ago

Please note this is distinct from https://github.com/npm/cli/issues/3235 because package-lock.json is not involved.