Skip to content
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

getting err @mistralai/mistralai v 0.1.3 doesn't support require way of importing library. i want to know the version of library which support it. #59

Open
Devmindtk opened this issue Apr 4, 2024 · 15 comments

Comments

@Devmindtk
Copy link

Devmindtk commented Apr 4, 2024

Error [ERR_REQUIRE_ESM]: require() of ES Module node_modules@mistralai\mistralai\src\client.js not supported. Instead change the require of client.js to a dynamic import() which is available in all CommonJS modules.

@Devmindtk Devmindtk changed the title getting err @mistralai/mistralai v 0.1.3 doesn't support require way of importing libraray. i want to know the version of library which support it. getting err @mistralai/mistralai v 0.1.3 doesn't support require way of importing library. i want to know the version of library which support it. Apr 4, 2024
@nico-crest
Copy link

Reproductible error here.
const mistralai_1 = require("@mistralai/mistralai"); ^ Error [ERR_REQUIRE_ESM]: require() of ES Module node_modules/@mistralai/mistralai/src/client.js from dist/app.service.js not supported. Instead change the require of client.js in cnc-scraping/dist/app.service.js to a dynamic import() which is available in all CommonJS modules.
Should we roll back to prior version ?

@Devmindtk
Copy link
Author

what do you mean by dynamic import?

@popmatik
Copy link

Also seeing this issue. Any resolution in the pipeline please?

@nbonamy
Copy link

nbonamy commented Apr 12, 2024

Seeing the same in an Electron app using vite.

@zognotadog
Copy link

Also seeing this issue when importing in typescript:

import  MistralClient from '@mistralai/mistralai';

const apiKey = process.env.MISTRAL_API_KEY;

const client = new MistralClient(apiKey);

@masad08
Copy link

masad08 commented Apr 17, 2024

same issue. any luck on why/fix?

@kndpt
Copy link

kndpt commented Apr 18, 2024

Same issue

@Bogatinovski
Copy link

We have identical error when trying to import in a typescript project. Any workaround?

@nbonamy
Copy link

nbonamy commented Apr 19, 2024

We have identical error when trying to import in a typescript project. Any workaround?

For now I just copied index.js in my project renamed it and imported it. Works for me.

@ptesny
Copy link

ptesny commented Apr 21, 2024

@Devmindtk , you can find in this blogpost Mistral gagnant. Mistral AI and SAP Kyma serverless.) a fully working solution of combining mistralai into a CJS module.

PS. Full recipe: mistral gagnant

@ptesny
Copy link

ptesny commented Apr 21, 2024

Reproductible error here. const mistralai_1 = require("@mistralai/mistralai"); ^ Error [ERR_REQUIRE_ESM]: require() of ES Module node_modules/@mistralai/mistralai/src/client.js from dist/app.service.js not supported. Instead change the require of client.js in cnc-scraping/dist/app.service.js to a dynamic import() which is available in all CommonJS modules. Should we roll back to prior version ?

@nico-crest ,
to address the reported error

please refer to my previous comment

@Robouste
Copy link

Robouste commented Jun 4, 2024

We have identical error when trying to import in a typescript project. Any workaround?

For now I just copied index.js in my project renamed it and imported it. Works for me.

What index.js are you talking about? Can you provide more guidance?

@ptesny
Copy link

ptesny commented Jun 4, 2024

@Robouste
I have already provide a solution in this thread

@Robouste
Copy link

Robouste commented Jun 4, 2024

@ptesny I know, I went through it but I don't see how to implement it with nestjs as I don't really understand it to be honest :)

In the end I went the old fashion way and call their API directly using axios

@nbonamy
Copy link

nbonamy commented Jun 5, 2024

We have identical error when trying to import in a typescript project. Any workaround?

For now I just copied index.js in my project renamed it and imported it. Works for me.

What index.js are you talking about? Can you provide more guidance?

src/client.js

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

10 participants