Skip to content

[BUG] npm install does not install correct versions when upgrading from npm 6 to 7 #3269

Description

@denis-sokolov

Is there an existing issue for this?

  • I have searched the existing issues

Current Behavior

Running npm install does not install correct versions of dependencies in place of the existing old versions if the lockfile includes a version change in addition to dependency version upgrades. See reproduction for more details.

Related or possibly a duplicate of: #3057, #3196.

Expected Behavior

After running npm install, the dependencies in node_modules should match the lockfile contents.

Steps To Reproduce

  1. git clone git@github.com:denis-sokolov/npm-6-to-7-old-dependency-reproduction.git && cd npm-6-to-7-old-dependency-reproduction
  2. git checkout base
  3. npm6 install (I used 6.14.9)
  4. git checkout master
  5. npm7 install (I used 7.11.2)
  6. cat node_modules/\@types/react-select/package.json | grep 'version":'

Observed:

"version": "3.0.22"

Expected:

"version": "4.0.15",

Workaround: rm -rf node_modules && npm install.

If reproduction fails, please see the with-node-modules branch that has node_modules included in the repository.

Environment

  • OS: macOS 11.3.1
  • Node: 14.14.0
  • npm: 7.11.2, also reproduced with 7.13.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    Bugthing that needs fixingRelease 7.xwork is associated with a specific npm 7 release

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions