Environment
- Astro: 4.11.3
- @astrojs/vercel: 7.7.2
Issue
I’m trying to deploy an Astro site to Vercel using Vercel Analytics, but I’m encountering an error related to the crypto
module not being defined. This configuration worked until I upgraded packages recently.
Configuration
Here’s my astro.config.mjs
:
import { defineConfig } from "astro/config";
import tailwind from "@astrojs/tailwind";
import vercel from "@astrojs/vercel/serverless";
import react from "@astrojs/react";
export default defineConfig({
integrations: [tailwind(), react()],
site: [MY DOMAIN HERE],
output: "server",
adapter: vercel({
webAnalytics: { enabled: true },
}),
});
The error I get says:
Unhandled Rejection: ReferenceError: crypto is not defined at decodeKey (file:///var/task/vercel/path0/.vercel/output/_functions/chunks/astro/server_D20XZRMg.mjs:1275:3) at deserializeManifest (file:///var/task/vercel/path0/.vercel/output/_functions/manifest_DlUM49nV.mjs:77:15) at file:///var/task/vercel/path0/.vercel/output/_functions/manifest_DlUM49nV.mjs:94:18 at ModuleJob.run (node:internal/modules/esm/module_job:195:25) at async ModuleLoader.import (node:internal/modules/esm/loader:337:24) at async importModuleDynamicallyWrapper (node:internal/vm/module:432:15) at async i (/opt/rust/nodejs.js:8:15915) Node.js process exited with exit status: 128. The logs above can help with debugging the issue.
I can comment out the webAnalytics line and it will run properly. Any suggestions?
Thanks!