Skip to content

[BUG] npm i pkg@tag should save tag into package.json #5052

@gemwuu

Description

@gemwuu

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

Running $ npm i lodash.has@latest will save lodash.has@^4.5.2 into package.json.

Expected Behavior

Save lodash.has@latest into package.json.

Steps To Reproduce

  1. npm i lodash.has@latest;
  2. package.json depedencies.lodash.has will be ^4.5.2

reason:users specify dist-tag installation should install the exact version that current dist-tag points to, not the moment when installation proceeds. If users want a semver of lodash.has, they should install with npm i lodash.has@^4.5.2.

Environment

  • npm: 8.12.2
  • Node.js: 16.13.0
  • OS Name: macOS Big Sur(version: 11.2.3)
  • System Model Name: MacBook Pro (16-inch, 2019)
  • npm config:
; copy and paste output from `npm config ls` here
; "user" config from /Users/tianding.wk/.npmrc

//registry.npmjs.com/:_authToken = (protected)
//registry.npmjs.org/:_authToken = (protected)
email = ""
strict-ssl = false

; node bin location = /Users/tianding.wk/.nvm/versions/node/v16.13.0/bin/node
; node version = v16.13.0
; npm local prefix = /Users/tianding.wk/workspace/tnpmregistry
; npm version = 8.12.2
; cwd = /Users/tianding.wk/workspace/tnpmregistry
; HOME = /Users/tianding.wk
; Run `npm config ls -l` to show all defaults.

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

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions