▲ 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
James2y ago
Try experimental-edge
Kent👋
Kent👋OP2y ago
export const config = { runtime: 'experimental-edge' };
export const config = { runtime: 'experimental-edge' };
Kent👋
Kent👋OP2y 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
James2y ago
Please send the full log.
Kent👋
Kent👋OP2y ago
Thanks 19:08:48.705 ▲ ./node_modules/.pnpm/@[email protected]/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
James2y 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👋OP2y ago
Is it possible to run the lib in worker with other tricks?
James
James2y 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