IBM / ibm-generative-ai-node-sdk

Library that provides convenient access to the Generative AI API from Node.js applications
MIT License
35 stars 6 forks source link

require way of accessing this library doesn't work. #96

Closed GouthamShiv closed 6 months ago

GouthamShiv commented 6 months ago

Using the latest version 2.0.2 and the require way of using the library is not working.

const Client = require('@ibm-generative-ai/node-sdk').Client

  - stack trace: Error [ERR_REQUIRE_ESM]: require() of ES Module /Users/my_app/node_modules/p-queue/dist/index.js from /Users/my_app/node_modules/@ibm-generative-ai/node-sdk/dist/index.cjs not supported.
Instead change the require of index.js in /Users/my_app/node_modules/@ibm-generative-ai/node-sdk/dist/index.cjs to a dynamic import() which is available in all CommonJS modules.
    at Object.<anonymous> (/Users/my_app/node_modules/@ibm-generative-ai/node-sdk/dist/index.cjs:230:30)
    at Object.<anonymous> (/Users/my_app/watsonx/promptLLM.js:10:16)
    at Object.<anonymous> (/Users/my_app/routes/genai_service.js:39:24)
    at /Users/my_app/node_modules/bhendi/mw/dispatcher.js:193:47
    at async Promise.all (index 2)
    at async /Users/my_app/node_modules/bhendi/mw/dispatcher.js:123:13
    at async Promise.all (index 0)
    at async /Users/my_app/node_modules/bhendi/mw/dispatcher.js:109:9
    at async Promise.all (index 0)
    at async Object.registerRoutes (/Users/my_app/node_modules/bhendi/mw/dispatcher.js:72:5)
    at async Object.init (/Users/my_app/node_modules/bhendi/bhendi.js:471:20)
    at async startServer (/Users/my_app/app.js:66:25)

Thanks!

pilartomas commented 6 months ago

Thank you for the report! Please try the latest release 2.0.4, the issue should be fixed there.

GouthamShiv commented 6 months ago

Works now! Thanks for the fix 👍🏽