diff --git a/package/src/common/configure.ts b/package/src/common/configure.ts index f8406df08b..a40b185fa8 100644 --- a/package/src/common/configure.ts +++ b/package/src/common/configure.ts @@ -18,13 +18,22 @@ import { configureDependency, kDependencies, } from "./dependencies/dependencies.ts"; -import { suggestUserBinPaths } from "../../../src/core/path.ts"; +import { suggestUserBinPaths, which } from "../../../src/core/path.ts"; import { buildQuartoPreviewJs } from "./previewjs.ts"; import { isWindows } from "../../../src/deno_ral/platform.ts"; export async function configure( config: Configuration, ) { + // npm is required later for building quarto-preview.js (used by `quarto + // preview` live-reload). Check upfront to fail fast before downloading + // hundreds of MB of dependencies when npm is missing. + if ((await which("npm")) === undefined) { + throw new Error( + "npm not found on PATH. Please install Node.js (which provides npm) before running configure.", + ); + } + // Download dependencies for (const dependency of kDependencies) { const targetDir = join(