Library is not compatible with nextjs
Problem
Describe the bug I found several issue when i try to build a nextjs application using openai-node : - Typescript compiler option isolatedModules is set to true => Cannot use 'export import' on a type or type-only namespace when 'isolatedModules' is enabled.ts(1269) - use of "#" to define a private property not working To Reproduce create a sample application with : npx create-next-app@latest install openai-node write a simple chatCompletion in a page component Launch "npm run build" You will see errors on "checking validity of types" step. Code snippets _No response_ OS macOs Node version 16.8.x and more Library version 4.00 and more
Unverified for your environment
Select your OS to check compatibility.
1 Fix
Solution: Library is not compatible with nextjs
"./node_modules/openai/src/index.ts" is the reason, your builder try to compile openai typescript with your own configuration, you need to import openai as a module, not directly by typescript filesource.
Trust Score
3 verifications
- 1
"./node_modules/openai/src/index.ts" is the reason, your builder try to compile
"./node_modules/openai/src/index.ts" is the reason, your builder try to compile openai typescript with your own configuration, you need to import openai as a module, not directly by typescript filesource.
Validation
Resolved in openai/openai-node GitHub issue #203. Community reactions: 3 upvotes.
Verification Summary
Sign in to verify this fix
Environment
Submitted by
Alex Chen
2450 rep