Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
2 tasks done
jkowalleck opened this issue Aug 28, 2023 · 4 comments
Closed
2 tasks done
Labels
Bug thing that needs fixing Priority 2 secondary priority issue Release 9.x work is associated with a specific npm 9 release

Comments

@jkowalleck
Copy link

jkowalleck commented Aug 28, 2023

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: [email protected]
     npm ERR! notsup Not compatible with your version of node/npm: [email protected]
     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.
@jkowalleck jkowalleck added Bug thing that needs fixing Needs Triage needs review for next steps Release 9.x work is associated with a specific npm 9 release labels Aug 28, 2023
@jkowalleck jkowalleck changed the title [BUG] <title> [BUG] npm install does not detect engine-compatble package properly Aug 28, 2023
@jkowalleck jkowalleck changed the title [BUG] npm install does not detect engine-compatble package properly [BUG] npm install does not detect engine-compatible package properly Aug 28, 2023
@golf-junkie
Copy link

I have exact the same issue though the version of nodejs is defferent.

Here is my environment.

  • npm: 9.8.1
  • Node.js: 16.20.2
  • OS Name: 4.14.320-242.534.amzn2.x86_64 #1 SMP Wed Jul 12 19:43:51 UTC 2023 x86_64 x86_64 x86_64 GNU/Linux

@jkowalleck
Copy link
Author

update: tested with npm from v6 to v10 -- latest each
all have this issue.

@milaninfy milaninfy added Priority 2 secondary priority issue and removed Needs Triage needs review for next steps labels Sep 17, 2024
@milaninfy
Copy link
Contributor

I created a local testing package with different versions supporting different engines

~/workarea/rep $ npm view pkgengine@"1||2||3||4||5||6" engines
[email protected] { node: '^18.0.0' }
[email protected] { node: '^19.0.0' }
[email protected] { node: '^20.0.0' }
[email protected] { node: '^21.0.0' }
[email protected] { node: '^22.0.0' }
[email protected] { node: '^23.0.0' }

it succeeds when it finds appropriate version satisfying the range and engine requirements and throws error otherwise.

~/workarea/rep $ node -v
v18.20.4
~/workarea/rep $ npm -v
10.8.3
~/workarea/rep $ npm i --engine-strict pkgengine@"^1||^2||^3||^4||^5"

added 1 package, and audited 2 packages in 565ms

found 0 vulnerabilities

~/workarea/rep $ npm ls
[email protected] /Users/milaninfy/workarea/rep
└── [email protected]

~/workarea/rep $ npm i --engine-strict pkgengine@"^2||^3||^4||^5" 
npm error code EBADENGINE
npm error engine Unsupported engine
npm error engine Not compatible with your version of node/npm: [email protected]
npm error notsup Not compatible with your version of node/npm: [email protected]
npm error notsup Required: {"node":"^22.0.0"}
npm error notsup Actual:   {"npm":"10.8.3","node":"v18.20.4"}
npm error A complete log of this run can be found in: /Users/milaninfy/.npm/_logs/2025-01-06T19_49_38_042Z-debug-0.log

appears to be fixed on [email protected] onwards

@jkowalleck
Copy link
Author

re: #6743 (comment)

thanks for the research. i will also check and see if i can reproduce the findings/results.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug thing that needs fixing Priority 2 secondary priority issue Release 9.x work is associated with a specific npm 9 release
Projects
None yet
Development

No branches or pull requests

3 participants