[▲ Vercel Community](/) · [Categories](/categories) · [Latest](/latest) · [Top](/top) · [Live](/live)

[Help](/c/help/9)

# Vercel Analytics causing a crash on my Astro Project

120 views · 2 likes · 6 posts


Stevegiralt (@stevegiralt) · 2024-08-15

## 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`:

```javascript
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!


Amy Egan (@amyegan) · 2024-08-15

Hey @stevegiralt. Which packages were updated, and what are the previous and current versions?

If you have a [minimal reproducible example](https://vercel.com/guides/creating-a-minimal-reproducible-example) repo, that's usually helpful to share so the rest of us can see exactly what you see.


Stevegiralt (@stevegiralt) · 2024-08-15 · ♥ 1

node_modules/astro 4.13.1 -> 4.13.2
@astrojs/compiler ^2.10.0->^2.10.1
node_modules/vite 5.3.5->5.4.0
node_modules/tailwindcss 3.4.7 -> 3.4.9
node_modules/foreground-child 3.2.1 -> 3.3.0

As for a reproducible example I can put one together and share asap


Amy Egan (@amyegan) · 2024-08-16

I would expect [crypto](https://developer.mozilla.org/en-US/docs/Web/API/Crypto) to be supported with Node.js 20. What version of Node.js does your project use? 

There's a related Next.js issue with more info: https://github.com/vercel/next.js/issues/46852#issuecomment-1457935256


Stevegiralt (@stevegiralt) · 2024-08-16 · ♥ 1

Thanks so much for the replies and the possible issue. My project uses Node 18.x - I might have a fix in place, I am testing on another branch and it appears to be working - 

The Astro documentation says to [set my output to "server"](https://docs.astro.build/en/guides/integrations-guide/vercel/#manual-install) , [as does the Vercel documentation](https://vercel.com/docs/frameworks/astro#using-vercel's-features-with-astro) - but I believe this is causing problems. Once I switched my output to "hybrid" it appears to function as intended.

I'm currently monitoring and investigating this fix and making sure it doesn't cause any other unintended issues.


Amy Egan (@amyegan) · 2024-08-17

I'm so glad you found a solution! Thank you for sharing it and please keep us updated on what you find :pray: