npm / npm/cli

[BUG] Npm not installing expected package version

Open
#3,411 7 comments 1 reaction 1 assignee View on GitHub

@isaacs is already working on this.

Since Jul 2, 2021.

Bug Needs Discussion Priority 2 Release 7.x
Dominant language
JavaScript
Stars
10.1k
Forks
4.7k
Avg merge
2d 2h
Merged PRs (30d)
19

Description

Is there an existing issue for this?
  • I have searched the existing issues
Current Behavior

When installing a new package with npm i <package_name>, if the package already exist as sub-dependencie of another package, it will install that version of the package (example 13.5.3). Instead of installing latest version (example 15.4.3). If that is a design choice, I find it counter-intuitive and hard to debug.

Expected Behavior
npm init
npm i @storybook/components
npm i react-syntax-highlighter

Should give me:

{
  "dependencies": {
    "@storybook/components": "^6.2.9",
    "react-syntax-highlighter": "^15.4.3"
  }
}

Doing npm i <package_name> when the package is absent from package.json should install the latest version by default of that package, ignoring smaller versions installed as sub-dependencie of other installed packages.

Steps To Reproduce
npm init
npm i react-syntax-highlighter
{
  "dependencies": {
    "react-syntax-highlighter": "^15.4.3"
  }
}

I have the latest version, hourra !


npm init
npm i @storybook/components
npm i react-syntax-highlighter
{
  "dependencies": {
    "@storybook/components": "^6.2.9",
    "react-syntax-highlighter": "^13.5.3"
  }
}

Why do I have 13.5.3 version ? It seem to be the same version as the one used by @storybook/components internally.

Environment
  • OS: Window 10
  • Node: v14.16.1
  • npm: 7.10.0

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.