Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

fix(dev): reliably detect path to bin for deps #6175

Merged
merged 1 commit into from
Apr 25, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions packages/remix-dev/devServer_unstable/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,17 @@ let patchPublicPath = (
};
};

let detectBin = async (): Promise<string> => {
let pkgManager = detectPackageManager() ?? "npm";
if (pkgManager === "npm") {
// npm v9 removed the `bin` command, so have to use `prefix`
let { stdout } = await execa(pkgManager, ["prefix"]);
return stdout.trim() + "/node_modules/.bin";
}
let { stdout } = await execa(pkgManager, ["bin"]);
return stdout.trim();
};

export let serve = async (
initialConfig: RemixConfig,
options: {
Expand All @@ -58,8 +69,7 @@ export let serve = async (
prevManifest?: Manifest;
} = {};

let pkgManager = detectPackageManager() ?? "npm";
let bin = (await execa(pkgManager, ["bin"])).stdout.trim();
let bin = await detectBin();
let startAppServer = (command: string) => {
console.log(`> ${command}`);
return execa.command(command, {
Expand Down