@@ -559,9 +559,9 @@ export function createNpmLockExecOptions(invocation, cwd, env = process.env) {
559559 } ;
560560}
561561
562- function runNpm ( args , cwd ) {
563- const npm = createNpmLockCommand ( args ) ;
564- execFileSync ( npm . command , npm . args , createNpmLockExecOptions ( npm , cwd ) ) ;
562+ function runNpm ( args , cwd , env = process . env ) {
563+ const npm = createNpmLockCommand ( args , { env } ) ;
564+ execFileSync ( npm . command , npm . args , createNpmLockExecOptions ( npm , cwd , env ) ) ;
565565}
566566
567567function packageExtensionAppliesToDependency ( selector , dependencyName ) {
@@ -764,7 +764,7 @@ function describeOverrideViolations(violations) {
764764 . join ( "; " ) ;
765765}
766766
767- function normalizeNpmLockOverrides ( tempDir , npmLockOverrides , npmInstallArgs ) {
767+ function normalizeNpmLockOverrides ( tempDir , npmLockOverrides , npmInstallArgs , env ) {
768768 const npmLockPath = path . join ( tempDir , "package-lock.json" ) ;
769769 const overrideRules = exactOverrideRulesFromOverrides ( npmLockOverrides ) ;
770770 if ( Object . keys ( overrideRules ) . length === 0 ) {
@@ -787,7 +787,7 @@ function normalizeNpmLockOverrides(tempDir, npmLockOverrides, npmInstallArgs) {
787787 // shrinkwraps as inactive, drop their cached subtree, then ask npm to recalculate this
788788 // package's authoritative lock with registry integrity hashes.
789789 writeFileSync ( npmLockPath , `${ JSON . stringify ( npmLock , null , 2 ) } \n` ) ;
790- runNpm ( npmInstallArgs , tempDir ) ;
790+ runNpm ( npmInstallArgs , tempDir , env ) ;
791791
792792 const normalized = JSON . parse ( readFileSync ( npmLockPath , "utf8" ) ) ;
793793 const remaining = collectOverrideViolations ( normalized , overrideRules ) ;
@@ -832,6 +832,7 @@ export function createNpmPackageLockInstallStrategyArgs(options = {}) {
832832export function generateNpmPackageLock ( packageDir , options = { } ) {
833833 const tempDir = mkdtempSync ( path . join ( tmpdir ( ) , "openclaw-npm-lock-" ) ) ;
834834 try {
835+ const env = options . env ?? process . env ;
835836 const packageJson = JSON . parse ( readFileSync ( path . join ( packageDir , "package.json" ) , "utf8" ) ) ;
836837 const npmLockOverrides = readNpmLockOverrides ( ) ;
837838 const peerResolutionArgs = shouldUseLegacyPeerDepsForNpmLock ( packageJson )
@@ -851,8 +852,8 @@ export function generateNpmPackageLock(packageDir, options = {}) {
851852 `${ JSON . stringify ( packageJsonForNpmLock ( packageJson , npmLockOverrides ) , null , 2 ) } \n` ,
852853 ) ;
853854 copyLocalFileDependencies ( packageJson , packageDir , tempDir ) ;
854- runNpm ( npmInstallArgs , tempDir ) ;
855- normalizeNpmLockOverrides ( tempDir , npmLockOverrides , npmInstallArgs ) ;
855+ runNpm ( npmInstallArgs , tempDir , env ) ;
856+ normalizeNpmLockOverrides ( tempDir , npmLockOverrides , npmInstallArgs , env ) ;
856857 const generated = normalizeNpmVersionDrift (
857858 applyPackageExtensionPeerMetadata (
858859 JSON . parse ( readFileSync ( path . join ( tempDir , "package-lock.json" ) , "utf8" ) ) ,
0 commit comments