Skip to content

Commit e4909bd

Browse files
authored
ci(NODE-7496): pin npm to 11.11.1 for Node 22 build variants (#4908)
1 parent 941e5fa commit e4909bd

2 files changed

Lines changed: 21 additions & 1 deletion

File tree

.evergreen/config.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1994,6 +1994,8 @@ tasks:
19941994
updates:
19951995
- {key: NODE_LTS_VERSION, value: '22'}
19961996
- func: install dependencies
1997+
vars:
1998+
NPM_VERSION: 11.11.1
19971999
- func: run unit tests
19982000
- name: run-unit-tests-node-24
19992001
tags:
@@ -3575,6 +3577,7 @@ buildvariants:
35753577
run_on: rhel80-large
35763578
expansions:
35773579
NODE_LTS_VERSION: 22
3580+
NPM_VERSION: 11.11.1
35783581
CLIENT_ENCRYPTION: 'true'
35793582
TEST_CSFLE: 'true'
35803583
tasks:
@@ -3782,6 +3785,7 @@ buildvariants:
37823785
run_on: windows-2022-latest-large
37833786
expansions:
37843787
NODE_LTS_VERSION: 22
3788+
NPM_VERSION: 11.11.1
37853789
CLIENT_ENCRYPTION: 'false'
37863790
TEST_CSFLE: 'false'
37873791
tasks:

.evergreen/generate_evergreen_tasks.js

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,14 @@ const {
2020
UBUNTU_22_OS
2121
} = require('./ci_matrix_constants');
2222

23+
// TODO(NODE-7499): unpin npm version once Node 22 ships a bundled npm that can upgrade itself
24+
const NODE22_NPM_VERSION = '11.11.1';
25+
26+
/** Returns the major version number from a Node.js version string (e.g. 'v22.11.0', '20.19.0', 22). */
27+
function nodeMajorVersion(version) {
28+
return semver.coerce(String(version))?.major;
29+
}
30+
2331
const OPERATING_SYSTEMS = [
2432
{
2533
name: DEFAULT_OS,
@@ -397,6 +405,12 @@ for (const {
397405
const expansions = { NODE_LTS_VERSION };
398406
const taskNames = tasks.map(({ name }) => name);
399407

408+
// bundled npm version in node v22.22.2 (v10.9.7) can't upgrade itself to @latest,
409+
// so we need to pin npm version for these variants to latest "upgradable" version
410+
if (nodeMajorVersion(NODE_LTS_VERSION) === 22) {
411+
expansions.NPM_VERSION = NODE22_NPM_VERSION;
412+
}
413+
400414
expansions.CLIENT_ENCRYPTION = String(!!clientEncryption);
401415
expansions.TEST_CSFLE = expansions.CLIENT_ENCRYPTION;
402416

@@ -478,7 +492,9 @@ const unitTestTasks = Array.from(
478492
updateExpansions({
479493
NODE_LTS_VERSION
480494
}),
481-
{ func: 'install dependencies' },
495+
nodeMajorVersion(NODE_LTS_VERSION) === 22
496+
? { func: 'install dependencies', vars: { NPM_VERSION: NODE22_NPM_VERSION } }
497+
: { func: 'install dependencies' },
482498
{ func: 'run unit tests' }
483499
]
484500
};

0 commit comments

Comments
 (0)