▲ error - Provided runtime "edge" is not supported.

Hi, I am creating a project with NextJs,in which there are some page functions under /pages/api/xxx.ts. I have read the docs from NextJs' site to adapt my code to cf pages env by adding the code below
export const config = { runtime: 'edge' };
export const config = { runtime: 'edge' };
or
export const runtime = 'edge';
export const runtime = 'edge';
But I got the following error.
17:35:16.870 ▲ info - Creating an optimized production build...
17:35:16.926 ▲ error - Provided runtime "edge" is not supported. Please leave it empty or choose one of: experimental-edge, nodejs
17:35:16.940 ▲ ELIFECYCLE  Command failed with exit code 1.
17:35:17.008 ▲ Error: Command "pnpm run build" exited with 1
17:35:17.117 ▲ ERROR  Command failed with exit code 1: vercel build
17:35:17.117 ▲
17:35:17.117 ▲ pnpm: Command failed with exit code 1: vercel build
17:35:17.118 ▲ at makeError (/opt/buildhome/.cache/node/corepack/pnpm/8.2.0/dist/pnpm.cjs:24230:17)
17:35:17.118 ▲ at handlePromise (/opt/buildhome/.cache/node/corepack/pnpm/8.2.0/dist/pnpm.cjs:24801:33)
17:35:17.118 ▲ at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
17:35:17.118 ▲ at async Object.handler [as dlx] (/opt/buildhome/.cache/node/corepack/pnpm/8.2.0/dist/pnpm.cjs:206486:7)
17:35:17.118 ▲ at async /opt/buildhome/.cache/node/corepack/pnpm/8.2.0/dist/pnpm.cjs:215818:21
17:35:16.870 ▲ info - Creating an optimized production build...
17:35:16.926 ▲ error - Provided runtime "edge" is not supported. Please leave it empty or choose one of: experimental-edge, nodejs
17:35:16.940 ▲ ELIFECYCLE  Command failed with exit code 1.
17:35:17.008 ▲ Error: Command "pnpm run build" exited with 1
17:35:17.117 ▲ ERROR  Command failed with exit code 1: vercel build
17:35:17.117 ▲
17:35:17.117 ▲ pnpm: Command failed with exit code 1: vercel build
17:35:17.118 ▲ at makeError (/opt/buildhome/.cache/node/corepack/pnpm/8.2.0/dist/pnpm.cjs:24230:17)
17:35:17.118 ▲ at handlePromise (/opt/buildhome/.cache/node/corepack/pnpm/8.2.0/dist/pnpm.cjs:24801:33)
17:35:17.118 ▲ at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
17:35:17.118 ▲ at async Object.handler [as dlx] (/opt/buildhome/.cache/node/corepack/pnpm/8.2.0/dist/pnpm.cjs:206486:7)
17:35:17.118 ▲ at async /opt/buildhome/.cache/node/corepack/pnpm/8.2.0/dist/pnpm.cjs:215818:21
I don't know why, thanks for your help.
9 Replies
James
James11mo ago
Try experimental-edge
Kent👋
Kent👋11mo ago
export const config = { runtime: 'experimental-edge' };
export const config = { runtime: 'experimental-edge' };
Kent👋
Kent👋11mo ago
19:09:02.300 ⚡️ 19:09:02.301 ⚡️ Please make sure that all your non-static routes export a config object specifying the edge runtime, like: 19:09:02.301 ⚡️ export const config = { runtime: 'edge' }; 19:09:02.301 ⚡️ 19:09:02.301 ⚡️ You can read more about the Edge Runtime on the Next.js documentation: 19:09:02.301 ⚡️ https://nextjs.org/docs/app/building-your-application/rendering/edge-and-nodejs-runtimes 19:09:02.301
19:09:02.339 Failed: Error while executing user command. Exited with error code: 1 19:09:02.349 Failed: build command exited with code: 1 19:09:03.205 Failed: error occurred while running build command
Rendering: Edge and Node.js Runtimes
Learn about the switchable runtimes (Edge and Node.js) in Next.js.
James
James11mo ago
Please send the full log.
Kent👋
Kent👋11mo ago
Thanks 19:08:48.705 ▲ ./node_modules/.pnpm/@paypal+paypalhttp@1.0.1/node_modules/@paypal/paypalhttp/lib/paypalhttp/serializer/multipart.js 19:08:48.705 ▲ A Node.js API is used (Buffer at line: 51) which is not supported in the Edge Runtime. I think that is the culprit. I involve some libs that aren't supported by edge environment
James
James11mo ago
Yeah, it looks like Next.js doesn't consider that library to be compatible with the edge runtime when it builds your app
Kent👋
Kent👋11mo ago
Is it possible to run the lib in worker with other tricks?
James
James11mo ago
Not if Next.js wont let you build the application - that error was an error from Next.js trying to build the route. The library would need to be made more compatible, or you would need a different library
Want results from more Discord servers?
Add your server
More Posts
Specifing the TLS version on an mTLS request?I am trying to connect to the BlackhawkNetwork (https://developer.blackhawknetwork.com/digital-gift-Using Cache API with gzipped R2 objectHi! I am trying to use the Cache API for a response that contains a gzip encoded html file (persistHelp Needed: Cloudflare Workers Memory Issue for Monthly Account StatementsHey! I'm working on a project using Cloudflare Workers to automatically send monthly account statemAjax website: Captcha validation on 403 ajax request answer - what's the best solutionWhat is the best solution for an AJAX website when on some user's requests get a 403 error? How to dHeaders ErrorHello, I keep getting the error: ```json { success: false, errors: [ { code: 6003, Cloudflare Workers Custom Domain resulting in ERR_EMPTY_RESPONSEHello everyone, I've been experiencing a problem with my custom domain on Cloudflare Workers. Here'Is there an example next.js on pages example repository?Are there any example repositories which incorporate some sort of api/backend/fetch example? I've beHow to connect my GKE backend to my pages?Trying to setup a small demo for cloudflare pages and have my static assets hosted. I have a GKE bacCall Azure function from a WorkerI need to call an Azure function (to run an script on NodeJS) from a CF Worker (Remix on Cf Pages). Every single time I open my website I get the "502 error code" and I have no clue what to fixI have gone to this website https://www.lifewire.com/502-bad-gateway-error-explained-2622939 and don