npm / npm/cli

[BUG] Performance regression between Node 22.17.1 and 22.18.0?

Open
#8,533 0 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Bug Needs Triage
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
This issue exists in the latest npm version
  • I am using the latest npm
Current Behavior

In a non-trivial project, running various npm scripts that I have see a significant slowdown when I switch my Node version from 22.17.1 to 22.18.0 (both using npm@11.5.2).

Initially thought that this might be a Node issue but what I believe that the regression surfaces when running npm run. For example, here's me running typescript checks using node --run using 22.17.1 and 22.18.0:

❯ hyperfine --warmup=3 "mise exec node@22.17.1 -- node --run types:renderer" "mise exec node@22.18.0 -- node --run types:renderer"

Benchmark 1: mise exec node@22.17.1 -- node --run types:renderer
  Time (mean ± σ):      7.198 s ±  0.191 s    [User: 13.740 s, System: 0.857 s]
  Range (min … max):    6.903 s …  7.543 s    10 runs
 
Benchmark 2: mise exec node@22.18.0 -- node --run types:renderer
  Time (mean ± σ):      7.324 s ±  0.215 s    [User: 13.979 s, System: 0.873 s]
  Range (min … max):    6.986 s …  7.706 s    10 runs
 
Summary
  mise exec node@22.17.1 -- node --run types:renderer ran
    1.02 ± 0.04 times faster than mise exec node@22.18.0 -- node --run types:renderer

Marginal difference between Node versions using node --run.

However, here's me doing the same thing but using npm run instead:

❯ hyperfine --warmup=3 "mise exec node@22.17.1 -- npm run types:renderer" "mise exec node@22.18.0 -- npm run types:renderer"

Benchmark 1: mise exec node@22.17.1 -- npm run types:renderer
  Time (mean ± σ):      7.461 s ±  0.112 s    [User: 14.177 s, System: 0.908 s]
  Range (min … max):    7.298 s …  7.629 s    10 runs
 
Benchmark 2: mise exec node@22.18.0 -- npm run types:renderer
  Time (mean ± σ):      8.862 s ±  0.352 s    [User: 14.150 s, System: 0.928 s]
  Range (min … max):    8.579 s …  9.750 s    10 runs
 
Summary
  mise exec node@22.17.1 -- npm run types:renderer ran
    1.19 ± 0.05 times faster than mise exec node@22.18.0 -- npm run types:renderer

I'm observing a 1.5 second average increase in execution time between 22.17.1 and 22.18.0 for a relatively straightforward script. The disparity becomes much more noticeable when running more complex npm scripts. For example, here's a script I have that runs some other scripts sequentially and in parallel using npm-run-all2:

❯ hyperfine --warmup=3 "mise exec node@22.17.1 -- npm run intl:translations" "mise exec node@22.18.0 -- npm run intl:translations"

Benchmark 1: mise exec node@22.17.1 -- npm run intl:translations
  Time (mean ± σ):      2.844 s ±  0.071 s    [User: 4.585 s, System: 0.768 s]
  Range (min … max):    2.767 s …  2.990 s    10 runs
 
Benchmark 2: mise exec node@22.18.0 -- npm run intl:translations
  Time (mean ± σ):     15.240 s ±  0.402 s    [User: 4.942 s, System: 0.862 s]
  Range (min … max):   14.692 s … 15.766 s    10 runs
 
Summary
  mise exec node@22.17.1 -- npm run intl:translations ran
    5.36 ± 0.19 times faster than mise exec node@22.18.0 -- npm run intl:translations

~3 seconds in Node 22.17.1 compared to ~15 seconds in Node 22.18.0!

Expected Behavior

Ideally there wouldn't be such a notable performance regression.

Steps To Reproduce

I don't have a set of concrete repro steps but here's the environment I'm working with:

  • macOS 15.6.1 (Sequoia)
  • npm 11.5.2
  • Using Node 22.17.1 and 22.18.0
Environment
  • npm: 11.5.2
  • Node.js: 22.18.0
  • OS Name: macOS
  • System Model Name: MacBook Pro 2019
  • npm config:
; "user" config from /Users/andrewchou/.npmrc

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

; node bin location = /Users/andrewchou/.local/share/mise/installs/node/22.18.0/bin/node
; node version = v22.18.0
; npm local prefix = /Users/andrewchou/GitHub/digidem/comapeo-desktop
; npm version = 11.5.2
; cwd = /Users/andrewchou/GitHub/digidem/comapeo-desktop
; HOME = /Users/andrewchou
; Run `npm config ls -l` to show all defaults.

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.

Research direction

Start by reproducing the reported hyperfine comparisons between Node 22.17.1 and 22.18.0 on macOS, using both node --run and npm run with the listed scripts. Compare the simpler types:renderer case with the intl:translations case and isolate the regression before changing code. Done means identifying a reproducible cause and preventing the performance loss without regressing the older version.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, nodejs
Domain
cli, performance
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.