question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Your nodejs instructions do not work

See original GitHub issue

I tried to switch over from mailgun-js to the official mailgun.js and everything broke. Following your official documentation:

const DOMAIN = "placeholderDomainHere"
const formData = require('form-data');
const Mailgun = require('mailgun.js');
const mailgun = new Mailgun(formData);
const mg = mailgun.client({username: 'api', key: process.env.MAILGUN_API_KEY);

mg.messages.create(DOMAIN, data)
    .then((result) => { console.log(result) } )
    .then((err) => { console.log(err) } )

it returns an error:

TypeError: this.formData is not a constructor

this is my current package version:

"form-data": "^4.0.0"
"mailgun.js": "^3.4.0"

Am I missing something here? If not, might want to consider updating the documentation to something that works? 😃

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:9 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
olexandr-mazepacommented, Jun 24, 2021

Hmm I think it seems to be working now. Not too sure what was going on there. Does this mean it only works with form-data@3.0.1 then? Should that be something that’s part of the documentation or am I mistaken? Apologies, am not a js developer so I am not 100% sure around the practices

It should work with fresher version of form-data package.(At least for me it works with “form-data”: “^4.0.0” and “mailgun.js”: “^3.4.0”). I may be wrong but It seems like you had some npm problem when you tried to install packages the previous time. You can try a newer version but before the install makes sure that you removed node_modules and package-lock.json file if they exist.

1reaction
Vaakmeistercommented, Jun 24, 2021

@jtsw1990 I think you’re issue is elsewhere then. It works fine for me based on the code you provided. You are however missing a closing } in this statement const mg = mailgun.client({username: 'api', key: process.env.MAILGUN_API_KEY); But from the error you gave it doesn’t match up with missing a closing brace.

Are you able to set up a minimal public repository to reproduce the issue and provide a stack trace of where the issue is occuring?

Read more comments on GitHub >

github_iconTop Results From Across the Web

15 Common Error Codes in Node.js and How to Fix Them
15. EPERM · Close all instances of your editor before rerunning the command (maybe some files were locked by the editor). · Clean...
Read more >
Troubleshoot your Node.js installation
If you have encountered any of these common problems after installing your New Relic Node.js agent, try these troubleshooting tips.
Read more >
Top 10 Most Common Node.js Developer Mistakes
Mistake #1: Blocking the event loop. JavaScript in Node.js (just like in the browser) provides a single threaded environment. This means that no...
Read more >
npm does not support Node.js v10.19.0 · Issue #3644
My node version is 10.19.0, and my npm version is 6.14. Here is the error message I am getting: npm does not support...
Read more >
Node.js is not working?
It looks like your Node.js installation is not working. To test it, either type nodejs or nodejs --version and see if it provides...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found