Skip to content

Commit 52f6a76

Browse files
committed
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 f946297 commit 52f6a76

1 file changed

Lines changed: 11 additions & 18 deletions

File tree

package/src/common/configure.ts

Lines changed: 11 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -25,15 +25,12 @@ import { isWindows } from "../../../src/deno_ral/platform.ts";
2525
export async function configure(
2626
config: Configuration,
2727
) {
28-
// npm is only required for building quarto-preview.js (used by `quarto preview`
29-
// for HTML/revealjs live-reload). Warn upfront so the user knows before the
30-
// long dependency downloads; the JS build is skipped below if npm is missing.
31-
const hasNpm = (await which("npm")) !== undefined;
32-
if (!hasNpm) {
33-
warning(
34-
"npm not found on PATH. The 'quarto preview' live-reload feature " +
35-
"will not be available. Install Node.js (which provides npm) and " +
36-
"re-run configure to enable it.",
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.",
3734
);
3835
}
3936

@@ -46,16 +43,12 @@ export async function configure(
4643
await configureDependency(dependency, targetDir, config);
4744
}
4845

49-
if (hasNpm) {
50-
info("Building quarto-preview.js...");
51-
const result = buildQuartoPreviewJs(config.directoryInfo.src);
52-
if (!result.success) {
53-
throw new Error();
54-
}
55-
info("Build completed.");
56-
} else {
57-
info("Skipping quarto-preview.js build (npm not found).");
46+
info("Building quarto-preview.js...");
47+
const result = buildQuartoPreviewJs(config.directoryInfo.src);
48+
if (!result.success) {
49+
throw new Error();
5850
}
51+
info("Build completed.");
5952

6053
// Move the quarto script into place
6154
info("Placing Quarto script");

0 commit comments

Comments
 (0)