From 89367f2bcfc8459ec286949be321a9100f771871 Mon Sep 17 00:00:00 2001 From: Tat Dat Duong Date: Fri, 14 Mar 2025 22:47:56 +0100 Subject: [PATCH] Fix Node 18.x support --- libs/langgraph-api/src/graph/load.hooks.mjs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/libs/langgraph-api/src/graph/load.hooks.mjs b/libs/langgraph-api/src/graph/load.hooks.mjs index 238e9dd..d8d24bf 100644 --- a/libs/langgraph-api/src/graph/load.hooks.mjs +++ b/libs/langgraph-api/src/graph/load.hooks.mjs @@ -20,10 +20,15 @@ export async function resolve(specifier, context, nextResolve) { // Node.js crashes with "TypeError [ERR_INVALID_URL_SCHEME]: The URL must be of scheme file". // As it already is a valid URI, we can just short-circuit the resolution and avoid `tsx`. if ( - specifier.includes("@tailwindcss/node/dist/esm-cache.loader.mjs") && + specifier.includes("@tailwindcss/node/dist/esm-cache.loader") && specifier.startsWith("file://") ) { - return { shortCircuit: true, url: specifier, format: "module" }; + return { + shortCircuit: true, + // Node 18.x will for some reason attempt to load `.mts` instead of `.mjs` + url: specifier.replace(".mts", ".mjs"), + format: "module", + }; } if (specifier === "@langchain/langgraph-checkpoint") {