Open Devmindtk opened 5 months ago
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 ?
what do you mean by dynamic import?
Also seeing this issue. Any resolution in the pipeline please?
Seeing the same in an Electron app using vite.
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);
same issue. any luck on why/fix?
Same issue
We have identical error when trying to import in a typescript project. Any workaround?
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.
@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
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
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 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
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
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.