Closed as not planned
Description
Confirm this is a Node library issue and not an underlying OpenAI API issue
- This is an issue with the Node library
Describe the bug
When importing the openai
package in Node.js 21 it throws an error:
(node:38591) [DEP0040] DeprecationWarning: The `punycode` module is deprecated. Please use a userland alternative instead.
at node:punycode:3:9
at BuiltinModule.compileForInternalLoader (node:internal/bootstrap/realm:392:7)
at BuiltinModule.compileForPublicLoader (node:internal/bootstrap/realm:328:10)
at loadBuiltinModule (node:internal/modules/helpers:101:7)
at Module._load (node:internal/modules/cjs/loader:1001:17)
at Module.require (node:internal/modules/cjs/loader:1235:19)
at require (node:internal/modules/helpers:176:18)
at Object.<anonymous> (/Users/adriaan/app/node_modules/whatwg-url/lib/url-state-machine.js:2:18)
at Module._compile (node:internal/modules/cjs/loader:1376:14)
at Module._extensions..js (node:internal/modules/cjs/loader:1435:10)
To Reproduce
package.json
:
{
"main": "index.js",
"type": "module",
"engines": {
"node": "21.2.0"
},
"scripts": {
"dev": "node --trace-deprecation -r dotenv/config index.js dotenv_config_path=.env.dev"
},
"dependencies": {
"openai": "^4.19.1"
},
"devDependencies": {
"dotenv": "^16.3.1"
}
}
index.js
:
import OpenAI from "openai";
console.log("hi");
.env.dev
:
OPENAI_API_KEY=
ASSISTANT_ID=
PORT=3011
BASE_URL=http://localhost:3011
Code snippets
No response
OS
macOS
Node version
v21.2.0
Library version
openai 4.19.1