Skip to content

Commit 8734812

Browse files
authored
Fail fast when npm is missing during configure (#14421)
* Warn and skip preview build when npm is missing during configure Check for npm at the start of configure() instead of failing late in buildQuartoPreviewJs() after ~300MB of downloads. When npm is missing, emit a warning explaining that the quarto preview live-reload feature will not be available, then skip the quarto-preview.js build step. The rest of Quarto (render, pdf, publish) builds and runs normally. * Error out instead of skipping when npm is missing A half-built Quarto without quarto-preview.js would later fail at runtime when `quarto preview` tries to read the missing file, producing another confusing error. Requiring npm upfront keeps the contract simple: configure succeeds only if all required tools are available.
1 parent 67d2311 commit 8734812

1 file changed

Lines changed: 10 additions & 1 deletion

File tree

package/src/common/configure.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,22 @@ import {
1818
configureDependency,
1919
kDependencies,
2020
} from "./dependencies/dependencies.ts";
21-
import { suggestUserBinPaths } from "../../../src/core/path.ts";
21+
import { suggestUserBinPaths, which } from "../../../src/core/path.ts";
2222
import { buildQuartoPreviewJs } from "./previewjs.ts";
2323
import { isWindows } from "../../../src/deno_ral/platform.ts";
2424

2525
export async function configure(
2626
config: Configuration,
2727
) {
28+
// npm is required later for building quarto-preview.js (used by `quarto
29+
// preview` live-reload). Check upfront to fail fast before downloading
30+
// hundreds of MB of dependencies when npm is missing.
31+
if ((await which("npm")) === undefined) {
32+
throw new Error(
33+
"npm not found on PATH. Please install Node.js (which provides npm) before running configure.",
34+
);
35+
}
36+
2837
// Download dependencies
2938
for (const dependency of kDependencies) {
3039
const targetDir = join(

0 commit comments

Comments
 (0)