workos / authkit-nextjs

The WorkOS library for Next.js provides convenient helpers for authentication and session management using WorkOS & AuthKit with Next.js.
MIT License
58 stars 14 forks source link

Error building due to unsupported Node.js API usage in Edge Runtime #8

Closed thinkininfinity closed 6 months ago

thinkininfinity commented 6 months ago

When attempting to build WorkOS's official Next.js example, I encountered the following error during the build process:

> next-authkit-example@0.1.0 build /Users/chongshengsun/Downloads/next-authkit-example
> next build

   ▲ Next.js 14.1.4
   - Environments: .env.local

   Creating an optimized production build ...
 ⚠ Compiled with warnings

./node_modules/.pnpm/@workos-inc+node@6.7.0/node_modules/@workos-inc/node/lib/workos.js
A Node.js API is used (process.emitWarning at line: 135) which is not supported in the Edge Runtime.
Learn more: https://nextjs.org/docs/api-reference/edge-runtime

Import trace for requested module:
./node_modules/.pnpm/@workos-inc+node@6.7.0/node_modules/@workos-inc/node/lib/workos.js
./node_modules/.pnpm/@workos-inc+node@6.7.0/node_modules/@workos-inc/node/lib/index.js
./node_modules/.pnpm/@workos-inc+nextjs@0.3.0_next@14.1.4_react-dom@18.2.0_react@18.2.0/node_modules/@workos-inc/nextjs/dist/cjs/workos.js
./node_modules/.pnpm/@workos-inc+nextjs@0.3.0_next@14.1.4_react-dom@18.2.0_react@18.2.0/node_modules/@workos-inc/nextjs/dist/cjs/authkit-callback-route.js
./node_modules/.pnpm/@workos-inc+nextjs@0.3.0_next@14.1.4_react-dom@18.2.0_react@18.2.0/node_modules/@workos-inc/nextjs/dist/cjs/index.js

./node_modules/.pnpm/@workos-inc+node@6.7.0/node_modules/@workos-inc/node/lib/workos.js
A Node.js API is used (process.emitWarning at line: 139) which is not supported in the Edge Runtime.
Learn more: https://nextjs.org/docs/api-reference/edge-runtime

Import trace for requested module:
./node_modules/.pnpm/@workos-inc+node@6.7.0/node_modules/@workos-inc/node/lib/workos.js
./node_modules/.pnpm/@workos-inc+node@6.7.0/node_modules/@workos-inc/node/lib/index.js
./node_modules/.pnpm/@workos-inc+nextjs@0.3.0_next@14.1.4_react-dom@18.2.0_react@18.2.0/node_modules/@workos-inc/nextjs/dist/cjs/workos.js
./node_modules/.pnpm/@workos-inc+nextjs@0.3.0_next@14.1.4_react-dom@18.2.0_react@18.2.0/node_modules/@workos-inc/nextjs/dist/cjs/authkit-callback-route.js
./node_modules/.pnpm/@workos-inc+nextjs@0.3.0_next@14.1.4_react-dom@18.2.0_react@18.2.0/node_modules/@workos-inc/nextjs/dist/cjs/index.js

This error indicates that @workos-inc/node library is using an unsupported Node.js API usage in Edge Runtime.

Could you please investigate this issue and provide guidance on how to resolve it? Is there a way to make the @workos-inc/node library compatible with Next.js's Edge Runtime?

thinkininfinity commented 6 months ago

duplicate https://github.com/workos/workos-node/issues/960