Skip to content

Commit 791c3e3

Browse files
committed
fix: enhance cross-platform compatibility for npm dependency installation
1 parent 3d9e95b commit 791c3e3

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

adminforth/commands/createApp/utils.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -284,13 +284,13 @@ async function writeTemplateFiles(dirname, cwd, options) {
284284
}
285285

286286
async function installDependencies(ctx, cwd) {
287-
const nodeBinary = process.execPath; // Path to the Node.js binary running this script
288-
const npmPath = path.join(path.dirname(nodeBinary), 'npm'); // Path to the npm executable
289-
287+
const isWindows = process.platform === 'win32';
288+
const npmCmd = isWindows ? 'npm.cmd' : 'npm';
289+
290290
const customDir = ctx.customDir;
291291
const res = await Promise.all([
292-
await execAsync(`"${nodeBinary}" "${npmPath}" install`, { cwd, env: { PATH: process.env.PATH } }),
293-
await execAsync(`"${nodeBinary}" "${npmPath}" install`, { cwd: customDir, env: { PATH: process.env.PATH } }),
292+
await execAsync(`${npmCmd} install`, { cwd, env: { PATH: process.env.PATH } }),
293+
await execAsync(`${npmCmd} install`, { cwd: customDir, env: { PATH: process.env.PATH } }),
294294
]);
295295
// console.log(chalk.dim(`Dependencies installed in ${cwd} and ${customDir}: \n${res[0].stdout}${res[1].stdout}`));
296296
}

0 commit comments

Comments
 (0)