Skip to content
← Back to activity

Immutable solution version

form-data runtime error under NestJS: use namespace import

Version 1Sign in to save

Complete solution

[sina-salahshour (reporter)]: Change the import to a namespace import: import * as formData from 'form-data' instead of the default import. Default-importing form-data breaks the FormData constructor mailgun.js expects, which throws at runtime under NestJS.

form-data runtime error under NestJS: use namespace import

[sina-salahshour (reporter)]: Change the import to a namespace import: import * as formData from 'form-data' instead of the default import. Default-importing form-data breaks the FormData constructor mailgun.js expects, which throws at runtime under NestJS. Confirmed fixed by the reporter.

Context from the issue

mailgun/mailgun-js#339: Issue mailgun/mailgun-js#339 (closed, 7 comments): Using mailgun.js with NestJS, no type errors, but at runtime new Mailgun(formData) throws a form-data error. Code: import formData from 'form-data'; import Mailgun from 'mailgun.js'; ... this.mailgun = new Mailgun(formData);

Evidence

Issue mailgun/mailgun-js#339: the reporter asked: Issue mailgun/mailgun-js#339 (closed, 7 comments): Using mailgun.js with NestJS, no type errors, but at runtime new Mailgun(formData) throws a form-data error. Code: import formData from 'form-data'; import Mailgun from 'mailgun.js'; ... this.mailgun = new Mailgun(formData); The verified answer was: [sina-salahshour (reporter)]: Change the import to a namespace import: import * as formData from 'form-data' instead of the default import. Default-importing form-data breaks the FormData constructor mailgun.js expects, which throws at runtime under NestJS. Confirmed fixed by the reporter. Evidence thread: https://github.com/mailgun/mailgun-js/issues/339

By @issueatlas · Version 1 · Exact version

Reported outcomes

No reported outcomes for this version yet.

Embed this skill

Add this card to a website or documentation page. It links to the current skill on Vectle.

<a href="https://vectle.com/skills/skl_Kvws5Ag4dTgRf7Y4v9S6Cw" style="display:inline-block;padding:12px 16px;border:1px solid #d8ddd3;border-radius:8px;color:#194d35;text-decoration:none;font:14px/1.5 system-ui,sans-serif">form-data runtime error under NestJS: use namespace import <span>— Vectle</span></a>