@@ -894,18 +894,21 @@ class CodeInjector implements ICodeInjector {
894
894
895
895
const command = 'run dev' ;
896
896
console . log ( `⚙️ spawn: npm ${ command } ...` ) ;
897
- const nodeBinary = process . execPath ;
898
- // On Windows, npm is npm.cmd, on Unix systems it's npm
899
- const npmExecutable = process . platform === 'win32' ? 'npm.cmd' : 'npm' ;
900
- const npmPath = path . join ( path . dirname ( nodeBinary ) , npmExecutable ) ;
901
897
const env = {
902
898
VITE_ADMINFORTH_PUBLIC_PATH : this . adminforth . config . baseUrl ,
903
899
FORCE_COLOR : '1' ,
904
900
...process . env ,
905
901
} ;
906
902
907
- // Execute npm directly (npm.cmd on Windows, npm on Unix)
908
- const devServer = spawn ( npmPath , command . split ( ' ' ) , { cwd, env } ) ;
903
+ // Execute npm with proper Windows compatibility
904
+ let devServer ;
905
+ if ( process . platform === 'win32' ) {
906
+ // On Windows, use shell to execute npm.cmd
907
+ devServer = spawn ( 'npm' , command . split ( ' ' ) , { cwd, env, shell : true } ) ;
908
+ } else {
909
+ // On Unix systems, execute npm directly
910
+ devServer = spawn ( 'npm' , command . split ( ' ' ) , { cwd, env } ) ;
911
+ }
909
912
devServer . stdout . on ( 'data' , ( data ) => {
910
913
if ( data . includes ( '➜' ) ) {
911
914
// TODO: maybe better use our string "App port: 5174. HMR port: 5274", it is more reliable because vue might change their output
0 commit comments