Skip to content

[BUG] npm install does not detect engine-compatible package properly #6743

Description

@jkowalleck

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

given: a package my-package exists in multiple versions

  • version 1.0 support node >=v14
  • version 1.1 support node >=v14
  • version 2.0 support node >=v16
  • version 2.1 support node >=v16

installing my-package@^1||^2 in a multi-version-range manner with option engine-strict enabled:

  • done on a node14 env: does not install anything, errors that version 2.1 is not supported by the current engine
  • done on a node16 env: installs version 2.1 with no problems

Expected Behavior

npm installer detects the highest engine-compatible version and installed it.

installing my-package@^1||^2 in a multi-version-range manner with option engine-strict enabled:

  • done on a node14 env: installs version 1.1 with no problems
  • done on a node16 env: installs version 2.1 with no problems

Steps To Reproduce

Prerequisite: normalize-package-data@^3 supports node14 as of
https://github.com/npm/normalize-package-data/blob/4121d78eb9d17a2ff738582de48429f8a84dd2c4/package.json#L38-L40

  1. In a fresh node14 environment
  2. Run npm init -y
  3. RUN npm i --engine-strict 'normalize-package-data@^3||^4||^5||^6'
  4. See error
     npm ERR! code EBADENGINE
     npm ERR! engine Unsupported engine
     npm ERR! engine Not compatible with your version of node/npm: normalize-package-data@6.0.0
     npm ERR! notsup Not compatible with your version of node/npm: normalize-package-data@6.0.0
     npm ERR! notsup Required: {"node":"^16.14.0 || >=18.0.0"}
     npm ERR! notsup Actual:   {"npm":"9.8.1","node":"v14.21.3"}
     
     npm ERR! A complete log of this run can be found in: .../.npm/_logs/2023-08-28T08_34_08_802Z-debug-0.log
    

Environment

  • npm: 9.8.1 -- tested also with npm@[6,7,8,9,10].x latest version each.
  • Node.js: v14.21.3
  • OS Name: Linux 5206377178b3 6.2.0-27-generic #28-Ubuntu SMP PREEMPT_DYNAMIC Wed Jul 12 22:39:51 UTC 2023 x86_64 GNU/Linux
  • System Model Name: docker node:14
  • npm config:
; node bin location = /usr/local/bin/node
; node version = v14.21.3
; npm local prefix = /tmp/dsdsadsd
; npm version = 9.8.1
; cwd = /tmp/dsdsadsd
; HOME = /...
; Run `npm config ls -l` to show all defaults.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Bugthing that needs fixingPriority 2secondary priority issueRelease 9.xwork is associated with a specific npm 9 release

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions