-
Notifications
You must be signed in to change notification settings - Fork 877
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
4.40.0 -> 4.40.1: Breaking change - OpenAI is not a constructor #816
Comments
At New Relic we instrument this package and this behavior is causing issues. I want to echo from what @YasharF has said that this was released in a patch and is a breaking change. This works fine when doing import OpenAI from 'openai';
const openai = new OpenAI({
apiKey: process.env['OPENAI_API_KEY'], // This is the default and can be omitted
}); so maybe the exports in package.json need updated as well to handle CJS? |
Using this package in a project and 4.40.1 breaks production builds due to this error. Works in local development environment. Reverting to 4.40.0 fixes it. |
Having a similar issue in tests where I stub |
This bot's PR seems the root cause 😄 #815 |
sorry about this, we're investigating. |
Thanks for reporting. Can you share your tsconfig to aid with repro? |
Ah... I thought my code had some issues.
Error: OpenAI is not a constructor Are you guys investigating this? |
The reproduction supplied in the opening report is plain JavaScript plus Node.js. There is no TypeScript involved. |
My report is also from a is in a pure JS repo. As reported above it works ok using ESM but CJS is where it fails. |
Minimal repro is simply: const OpenAi = require('openai');
const client = new OpenAi(); $ node index.js
TypeError: OpenAi is not a constructor..... |
this will be fixed in the next release: #818 |
@RobertCraigie when can we expect the fix version release in NPM |
This has been fixed in |
@RobertCraigie Thank you! To whom in OpenAI may I send an invoice for the 4 hours of developer time spent troubleshooting this? ;) |
Thanks a lot , finally working this. |
No, this hasn’t been fixed. I’m still having the problem on the latest version, 4.51. |
Same here but only after I tried to implement datadog. |
@dreamsavior Please open another GitHub issue if you're still having problems with the latest version of the SDK |
Confirm this is a Node library issue and not an underlying OpenAI API issue
Describe the bug
Based on numbers, 4.40.1 is supposed to be a bug fix release over 4.40.0, so I didn't expect something to break. I have not tested the application after 4.40.1 to see if anything else is broken.
const openai = new OpenAI({
^
TypeError: OpenAI is not a constructor
To Reproduce
Code saved as test.js:
Code snippets
No response
OS
WSL Ubuntu 24.04 LTS
Node version
v20.12.2
Library version
4.40.1
The text was updated successfully, but these errors were encountered: