Skip to content

[DOCS] npm doesn't install the latest tagged version if engines are invalid #7704

@richardlau

Description

@richardlau

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 install @pkgjs/support or npx @pkgjs/support validate will install an outdated version of the package (0.0.2 instead of 0.0.6 which is also tagged latest).

Expected Behavior

The latest version of @pkgjs/support is installed/used.

Steps To Reproduce

npx

  1. Run npx @pkgjs/support validate with Node.js 22.5.1 (npm 10.8.2) Linux x64
$ npm version
{
  npm: '10.8.2',
  node: '22.5.1',
  acorn: '8.11.3',
  ada: '2.9.0',
  ares: '1.32.1',
  brotli: '1.1.0',
  cjs_module_lexer: '1.2.2',
  cldr: '45.0',
  icu: '75.1',
  llhttp: '9.2.1',
  modules: '127',
  napi: '9',
  nbytes: '0.1.0',
  nghttp2: '1.62.1',
  nghttp3: '0.7.0',
  ngtcp2: '1.3.0',
  openssl: '3.0.13+quic',
  simdjson: '3.9.4',
  simdutf: '5.3.0',
  sqlite: '3.46.0',
  tz: '2024a',
  undici: '6.19.2',
  unicode: '15.1',
  uv: '1.48.0',
  uvwasi: '0.0.21',
  v8: '12.4.254.21-node.16',
  zlib: '1.3.0.1-motley-209717d'
}
$ npx @pkgjs/support validate
npm error could not determine executable to run
npm error A complete log of this run can be found in: /home/rlau/.npm/_logs/2024-08-06T15_47_54_908Z-debug-0.log
$

According to the debug log, @pkgjs/support@0.0.2 was used (where the error makes sense as there is no bin for version 0.0.2: https://registry.npmjs.org/@pkgjs%2fsupport).

$ cat /home/rlau/.npm/_logs/2024-08-06T15_47_54_908Z-debug-0.log
0 verbose cli /home/rlau/.nvm/versions/node/v22.5.1/bin/node /home/rlau/.nvm/versions/node/v22.5.1/lib/node_modules/npm/bin/npm-cli.js
1 info using npm@10.8.2
2 info using node@v22.5.1
3 silly config load:file:/home/rlau/.nvm/versions/node/v22.5.1/lib/node_modules/npm/npmrc
4 silly config load:file:/tmp/new/.npmrc
5 silly config load:file:/home/rlau/.npmrc
6 silly config load:file:/home/rlau/.nvm/versions/node/v22.5.1/etc/npmrc
7 verbose title npm exec @pkgjs/support validate
8 verbose argv "exec" "--" "@pkgjs/support" "validate"
9 verbose logfile logs-max:10 dir:/home/rlau/.npm/_logs/2024-08-06T15_47_54_908Z-
10 verbose logfile /home/rlau/.npm/_logs/2024-08-06T15_47_54_908Z-debug-0.log
11 silly logfile start cleaning logs, removing 1 files
12 silly logfile done cleaning log files
13 silly packumentCache heap:4345298944 maxSize:1086324736 maxEntrySize:543162368
14 http fetch GET 200 https://registry.npmjs.org/@pkgjs%2fsupport 592ms (cache miss)
15 verbose stack Error: could not determine executable to run
15 verbose stack     at getBinFromManifest (/home/rlau/.nvm/versions/node/v22.5.1/lib/node_modules/npm/node_modules/libnpmexec/lib/get-bin-from-manifest.js:17:23)
15 verbose stack     at exec (/home/rlau/.nvm/versions/node/v22.5.1/lib/node_modules/npm/node_modules/libnpmexec/lib/index.js:202:15)
15 verbose stack     at async Npm.exec (/home/rlau/.nvm/versions/node/v22.5.1/lib/node_modules/npm/lib/npm.js:207:9)
15 verbose stack     at async module.exports (/home/rlau/.nvm/versions/node/v22.5.1/lib/node_modules/npm/lib/cli/entry.js:74:5)
16 verbose pkgid @pkgjs/support@0.0.2
17 error could not determine executable to run
18 verbose cwd /tmp/new
19 verbose os Linux 5.14.0-284.11.1.el9_2.x86_64
20 verbose node v22.5.1
21 verbose npm  v10.8.2
22 verbose exit 1
23 verbose code 1
24 error A complete log of this run can be found in: /home/rlau/.npm/_logs/2024-08-06T15_47_54_908Z-debug-0.log
$

Problem does not occur with Node.js 22.4.1 and npm 10.8.1.

We first notice this happen in https://github.com/nodeshift/openshift-rest-client/actions/runs/10268248192/job/28410980498?pr=420 when attempting to add Node.js 22 to our existing GitHub Workflow.

npm install

  1. In an empty directory/new package...
  2. Run npm install @pkgjs/support.
$ npm install @pkgjs/support

added 7 packages in 1s

1 package is looking for funding
  run `npm fund` for details
$
  1. Observe that pkgjs/support@0.0.2 is installed:
$ npm ls
new@ /tmp/new
└── @pkgjs/support@0.0.2
$

Problem does not occur with Node.js 22.4.1 and npm 10.8.1.

Environment

  • npm: 10.8.2
  • Node.js: 22.5.1
  • OS Name: Linux
  • System Model Name:
  • npm config:
; "user" config from /home/rlau/.npmrc

//registry.npmjs.org/:_authToken = (protected)

; node bin location = /home/rlau/.nvm/versions/node/v22.5.1/bin/node
; node version = v22.5.1
; npm local prefix = /tmp/new
; npm version = 10.8.2
; cwd = /tmp/new
; HOME = /home/rlau
; Run `npm config ls -l` to show all defaults.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Documentationdocumentation related issuePriority 2secondary priority issue

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions