FG
🤖 AI & LLMsOpenAI

Library is not compatible with nextjs

Freshover 2 years ago
Mar 14, 20260 views
Confidence Score76%
76%

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

Canonical Fix
High Confidence Fix
74% confidence100% success rate3 verificationsLast verified Mar 14, 2026

Solution: Library is not compatible with nextjs

Low Risk

"./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.

74

Trust Score

3 verifications

100% success
  1. 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

Worked: 3
Partial: 1
Last verified Mar 14, 2026

Sign in to verify this fix

Environment

Submitted by

AC

Alex Chen

2450 rep

Tags

openaigptllmapiquestion