-
Notifications
You must be signed in to change notification settings - Fork 873
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
The punycode
module is deprecated in Node.js 21 (type = module)
#527
Comments
Sorry about that; thanks for reporting. This looks to be coming from The good news is we're planning to move from That'll probably be a breaking change, so it won't come out til we're able to do a major version bump. In the short term, you can work around this by overriding the dependency in your "overrides": {
"whatwg-url": "13.0.0"
} |
Thanks for the help! I moved back to Node.js 20 for now. What also could be a solution is to use native Node.js fetch from version 21. It's not experimental anymore and included in the default distributions. |
The openai package transitively depends on an outdated version of whatwg-url, which causes nodejs to print a deprecation warning for punycode when running the vision tool. This will be fixed when openai resolves openai/openai-node#392. Until then, override the version of whatwg-url in order to prevent the deprecation warning. See openai/openai-node#527 (comment) for details on this stopgap. Signed-off-by: Nick Hale <4175918+njhale@users.noreply.github.com>
This is still an issue. Caused a bit of an explanation at a client who saw the logs that openai itself is using deprecated imports in the dependency chain. |
Sorry about that. This issue will be fixed by #402 and won't be tackled before, so I'll close this as a duplicate. |
An option would be to rely on a patch utility such as https://github.com/ds300/patch-package to patch But I don't believe that can be done for libraries such as the openai sdk itself, that would need to be done as part of the project importing the sdk. |
@dgellow Please don't! Modules are not supposed to be patched like this. It will create all sorts of problems, especially with pnpm, where modules are linked instead of installed per project. The right choice is not to import a fetch polyfill, when there is fetch natively, and choose a good polyfill like @adobe/fetch instead of node-fetch only if needed when running in an outdated environment. Node-fetch by now is the new request module. Just bloated and has problems with memory leaks. Last not but least: It is kinda funny, that a company like openai, with something as smart as GPT 4 can't produce a proper isomorphic TypeScript client, but instead relies on node.js specific APIs. |
Actually pnpm supports that patching feature natively via |
As noted above, we are working on moving to native We also document a non- |
Hey, this does not work for me, why?
|
- openai/openai-node#527 - whatwg-url@13.0.0으로 override 이후 puncycode 경고가 없어짐 - 현재 사용하지 않는 ts-node 종속성 제거
Hey, this does not work for me, why? Here is my package.json in root directory. Thanks! Make sure you run |
Hey, this does not work for me, why? Here is my package.json in root directory. Thanks! ``` { "overrides": { "whatwg-url": "13.0.0" } } ``` Worked, thanks. |
Overriding "whatwg-url" worked for me too (the last two days), but today I get a punycode deprecation warning again:
|
Hey, this does not work for me, why? Here is my package.json in root directory. Thanks! ``` { "overrides": { "whatwg-url": "13.0.0" } } ``` you saved my life |
Confirm this is a Node library issue and not an underlying OpenAI API issue
Describe the bug
When importing the
openai
package in Node.js 21 it throws an error:To Reproduce
package.json
:index.js
:.env.dev
:Code snippets
No response
OS
macOS
Node version
v21.2.0
Library version
openai 4.19.1
The text was updated successfully, but these errors were encountered: