@@ -130,14 +130,30 @@ class CodeInjector implements ICodeInjector {
130
130
process . env . HEAVY_DEBUG && console . log ( `🪲 npm ${ command } cwd:` , cwd ) ;
131
131
process . env . HEAVY_DEBUG && console . time ( `npm ${ command } done in` ) ;
132
132
133
- // Quote paths that contain spaces (especially important on Windows)
134
- const quotedNodeBinary = nodeBinary . includes ( ' ' ) ? `"${ nodeBinary } "` : nodeBinary ;
135
- const quotedNpmPath = npmPath . includes ( ' ' ) ? `"${ npmPath } "` : npmPath ;
133
+ // On Windows, execute npm.cmd directly; on Unix, use node + npm
134
+ let execCommand : string ;
135
+ if ( process . platform === 'win32' ) {
136
+ // Quote path if it contains spaces
137
+ const quotedNpmPath = npmPath . includes ( ' ' ) ? `"${ npmPath } "` : npmPath ;
138
+ execCommand = `${ quotedNpmPath } ${ command } ` ;
139
+ } else {
140
+ // Quote paths that contain spaces (for Unix systems)
141
+ const quotedNodeBinary = nodeBinary . includes ( ' ' ) ? `"${ nodeBinary } "` : nodeBinary ;
142
+ const quotedNpmPath = npmPath . includes ( ' ' ) ? `"${ npmPath } "` : npmPath ;
143
+ execCommand = `${ quotedNodeBinary } ${ quotedNpmPath } ${ command } ` ;
144
+ }
136
145
137
- const { stdout : out , stderr : err } = await execAsync ( ` ${ quotedNodeBinary } ${ quotedNpmPath } ${ command } ` , {
146
+ const execOptions : any = {
138
147
cwd,
139
148
env,
140
- } ) ;
149
+ } ;
150
+
151
+ // On Windows, use shell to execute .cmd files
152
+ if ( process . platform === 'win32' ) {
153
+ execOptions . shell = true ;
154
+ }
155
+
156
+ const { stdout : out , stderr : err } = await execAsync ( execCommand , execOptions ) ;
141
157
process . env . HEAVY_DEBUG && console . timeEnd ( `npm ${ command } done in` ) ;
142
158
143
159
// process.env.HEAVY_DEBUG && console.log(`🪲 npm ${command} output:`, out);
0 commit comments