You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Out of the box, the TypeScript example at fails to compile:
node --loader=ts-node/esm index.ts
(node:20) ExperimentalWarning: `--experimental-loader` may be removed in the future; instead use `register()`:
--import 'data:text/javascript,import { register } from "node:module"; import { pathToFileURL } from "node:url"; register("ts-node/esm", pathToFileURL("./"));'
(Use `node --trace-warnings ...` to show where the warning was created)
file:///home/projects/stackblitz-starters-bkpyr8/index.ts:2
import { Client } from 'node-mailjet';
^^^^^^
SyntaxError: Named export 'Client' not found. The requested module 'node-mailjet' is a CommonJS module, which may not support all module.exports as named exports.
CommonJS modules can always be imported via the default export, for example using:
import pkg from 'node-mailjet';
const { Client } = pkg;
at _instantiate (node:internal/modules/esm/module_job:155:1617)
Same problem, Issue is where node.js project use ESM and import mailjet client using named export.
We use following workaround
importtype{Client}from"node-mailjet";importMailjetfrom"node-mailjet";// @see https://github.com/mailjet/mailjet-apiv3-nodejs/issues/281// @ts-expect-error Problem in library export and commonjsthis.client=newMailjet({
apiKey,
apiSecret,config: {version: "v3.1",},})asClient;
Out of the box, the TypeScript example at fails to compile:
node --loader=ts-node/esm index.ts
Node.js 18.20.3
Online demo: https://stackblitz.com/edit/stackblitz-starters-bkpyr8?file=index.ts&view=editor
PS: is this module maintained any more? There hasn't been any activity since November.
The text was updated successfully, but these errors were encountered: