Next.js Discord

Discord Forum

unhandledRejection ReferenceError: crypto is not defined

Unanswered
Olive-backed Pipit posted this in #help-forum
Open in Discord
Olive-backed PipitOP
My next js is not able to build in vercel.

I tried adding this into my tsconfig.json
"paths": { "crypto": [ "node_modules/crypto-js" ] }

Also tried adding this in my package.json
"browser": { "crypto": false }

Now locally app builds just fine without these lines of code, but in vercel it just fails every time.

2 Replies

Try this in your next config
/** @type {import('next').NextConfig} */
const nextConfig = {
  transpilePackages: ["crypto-js"],
};

module.exports = nextConfig;
This could also be due to you trying to use an npm package in the wrong environment (client and server)