▲ 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
or
But I got the following error.
I don't know why, thanks for your help.9 Replies
Try
experimental-edge
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
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.
Please send the full log.
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
Yeah, it looks like Next.js doesn't consider that library to be compatible with the edge runtime when it builds your app
Is it possible to run the lib in worker with other tricks?
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