summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.changeset/twelve-gifts-attend.md5
-rw-r--r--packages/astro/src/core/config/vite-load.ts7
2 files changed, 12 insertions, 0 deletions
diff --git a/.changeset/twelve-gifts-attend.md b/.changeset/twelve-gifts-attend.md
new file mode 100644
index 000000000..ccc27dde1
--- /dev/null
+++ b/.changeset/twelve-gifts-attend.md
@@ -0,0 +1,5 @@
+---
+'astro': patch
+---
+
+Display useful errors when config loading fails because of Node addons being disabled on Stackblitz
diff --git a/packages/astro/src/core/config/vite-load.ts b/packages/astro/src/core/config/vite-load.ts
index cf6e4a0b0..d6b86b02e 100644
--- a/packages/astro/src/core/config/vite-load.ts
+++ b/packages/astro/src/core/config/vite-load.ts
@@ -34,6 +34,13 @@ export async function loadConfigWithVite({
const config = await import(pathToFileURL(configPath).toString() + '?t=' + Date.now());
return config.default ?? {};
} catch (e) {
+ // Normally we silently ignore loading errors here because we'll try loading it again below using Vite
+ // However, if the error is because of addons being disabled we rethrow it immediately,
+ // because when this happens in Stackblitz, the Vite error below will be uncatchable
+ // and we want to provide a more helpful error message.
+ if (e && typeof e === 'object' && 'code' in e && e.code === 'ERR_DLOPEN_DISABLED') {
+ throw e;
+ }
// We do not need to throw the error here as we have a Vite fallback below
debug('Failed to load config with Node', e);
}