@@ -400,12 +400,16 @@ export async function runVersion(locator: Locator, installSpec: InstallSpec & {s
400
400
if ( ! binPath )
401
401
throw new Error ( `Assertion failed: Unable to locate path for bin '${ binName } '` ) ;
402
402
403
- // Node.js segfaults when using npm@>=9.7.0 and v8-compile-cache
404
- // $ docker run -it node:20.3.0-slim corepack npm@9.7.1 --version
405
- // [SIGSEGV]
406
- if ( locator . name !== `npm` || semverLt ( locator . reference , `9.7.0` ) )
407
- // @ts -expect-error - No types
408
- await import ( `v8-compile-cache` ) ;
403
+ // @ts -expect-error - Missing types
404
+ if ( ! Module . enableCompileCache ) {
405
+ // Node.js segfaults when using npm@>=9.7.0 and v8-compile-cache
406
+ // $ docker run -it node:20.3.0-slim corepack npm@9.7.1 --version
407
+ // [SIGSEGV]
408
+ if ( locator . name !== `npm` || semverLt ( locator . reference , `9.7.0` ) ) {
409
+ // @ts -expect-error - No types
410
+ await import ( `v8-compile-cache` ) ;
411
+ }
412
+ }
409
413
410
414
// We load the binary into the current process,
411
415
// while making it think it was spawned.
@@ -429,6 +433,12 @@ export async function runVersion(locator: Locator, installSpec: InstallSpec & {s
429
433
// Use nextTick to unwind the stack, and consequently remove Corepack from
430
434
// the stack trace of the package manager.
431
435
process . nextTick ( Module . runMain , binPath ) ;
436
+
437
+ // @ts -expect-error - No types
438
+ if ( Module . flushCompileCache ) {
439
+ // @ts -expect-error - No types
440
+ setImmediate ( Module . flushCompileCache ) ;
441
+ }
432
442
}
433
443
434
444
export function shouldSkipIntegrityCheck ( ) {
0 commit comments