@@ -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+
2331const 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