Skip to content

Commit ce84b0f

Browse files
committed
fix: enhance npm command execution for Windows compatibility by using Node.js binary path
1 parent c73dcb0 commit ce84b0f

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

adminforth/modules/codeInjector.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -900,14 +900,14 @@ class CodeInjector implements ICodeInjector {
900900
...process.env,
901901
};
902902

903-
// Execute npm with proper Windows compatibility
903+
const nodeBinary = process.execPath;
904+
const npmPath = path.join(path.dirname(nodeBinary), 'npm');
905+
904906
let devServer;
905907
if (process.platform === 'win32') {
906-
// On Windows, use shell to execute npm.cmd
907908
devServer = spawn('npm', command.split(' '), { cwd, env, shell: true });
908909
} else {
909-
// On Unix systems, execute npm directly
910-
devServer = spawn('npm', command.split(' '), { cwd, env });
910+
devServer = spawn(`${nodeBinary}`, [`${npmPath}`, ...command.split(' ')], { cwd, env });
911911
}
912912
devServer.stdout.on('data', (data) => {
913913
if (data.includes('➜')) {

0 commit comments

Comments
 (0)