[Bug] Module build failed: UnhandledSchemeError: Reading from "node:buffer" is not handled by plugins (Unhandled scheme) - runtime: `browser` nextjs react react-query
Describe the Bug
Trying to use the generated SDK for Typescript inside a React app with Next.js in browser runtime (use client) trigger this error
Module build failed: UnhandledSchemeError: Reading from "node:buffer" is not handled by plugins (Unhandled scheme).
All working in a Server Component that use Node runtime. Tested only in local dev.
Information to Reproduce
CLI Version
{
"organization": "xxxxx",
"version": "0.43.5"
}
Generator Version
default-group: local
groups:
local:
generators:
- name: fernapi/fern-typescript-node-sdk
version: 0.39.3
output:
location: local-file-system
path: ../sdks/typescript
api:
path: openapi/openapi.yml
API Definition
Irrelevant.
Actual SDK
Don't know what to write here
Expected SDK
Don't know what to write here
I presume this is expected behavior, meaning that the SDK is not supposed to work on browser runtime. It's my first time using fern.
In case is not supported, is planned for the future ?
@tresorama can you:
- disable these in your package.json
- turn on the config flag for
outputEsmand see if that works
disable these in your package.json
In package.json of sdk consumer app (next.js) or in the project that generate the sdk ?
- turn on the config flag for outputEsm and see if that works
Where do I add this ?
My current setup
.
├── backend (fastify + fastify-swagger)
│ ├── package.json
│ ├── src
│ │ ├── plugins
│ │ │ └── fastify-swagger
│ │ └── server.ts
│ └── tsconfig.json
├── frontend (next js)
│ ├── next.config.mjs
│ ├── package.json
│ ├── src
│ │ ├── app
│ │ │ ├── dashboard
│ │ │ ├── globals.css
│ │ │ ├── layout.tsx
│ │ ├── auth
│ │ │ └── auth.login.tsx
│ │ └── lib
│ │ ├── fetcher
│ │ ├── react-query.tsx
│ │ └── utils.ts
│ ├── tailwind.config.ts
│ └── tsconfig.json
└── openapi (fern cli )
├── fern
│ ├── fern.config.json
│ ├── generators.yml
│ └── openapi
│ └── openapi.yml
├── package.json
└── sdks
└── typescript
├── Client.d.ts
├── Client.js
├── api
├── core
├── environments.d.ts
├── environments.js
├── errors
├── index.d.ts
├── index.js
└── serialization
@tresorama sorry for the delayed reply here!
You can add the config flag for outputEsm via your generators.yml:
https://github.com/fern-api/fern/blob/main/generators/typescript/README.md#-outputesm