module not found can't resolve

342 views
Skip to first unread message

Eric Downey

unread,
Feb 21, 2020, 12:20:42 PM2/21/20
to Angular and AngularJS discussion
I recently started working with Angular and created a pwa that allowed users in my board gaming club to submit results from their games.  The end result is an email containing the form info sent to myself and the league manager.  The form works great but as soon as I installed the mailgun package and tried to use var mailgun = require('mailgun-js')({apiKey: api_key, domain: domain}); I started to get a bunch of the following for various modules.  I have no idea how to fix this or what the root cause is.  Any suggestions would be greatly appreciated.

[ng] ERROR in ./node_modules/pac-resolver/dnsResolve.js
[ng] Module not found: Error: Can't resolve 'dns' in 'C:\Users\Phil\src\iw40klv2\node_modules\pac-resolver'

Sander Elias

unread,
Feb 23, 2020, 8:43:52 AM2/23/20
to Angular and AngularJS discussion
Hi Eric,

Try using `import(..).then(mg => {})` instead of require. Tha t will trigger the tooling to make a package that is distributed to the client.

Regards
Sander

Eric Downey

unread,
Feb 23, 2020, 10:54:06 PM2/23/20
to ang...@googlegroups.com
Hi,

Thanks so much for the reply and suggestion!  I tried using this:

import { nodemailer } from 'nodemailer';

but still got the same errors.  Could be there's something about import I'm missing as I'm really new to typescript/nodejs/etc :P  I get this error with a lot of modules I've been trying to use.  Not the simple ones like chalk but nodemailer and mailgun-js are causing module not found issues.  Since it's happening with more than one and not the same missing modules I figure it's something I'm doing.  If there's anything else you can think of please let me know.  I'm a c# developer by trade and want to move into the typescript/node arena and can't believe I'm getting hung up on this...

Thanks,

Eric

--
You received this message because you are subscribed to the Google Groups "Angular and AngularJS discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to angular+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/angular/87bb77a4-8835-4ec8-ac7b-c1ee6f140666%40googlegroups.com.

Sander Elias

unread,
Feb 26, 2020, 11:40:52 AM2/26/20
to Angular and AngularJS discussion
Hi Eric,

Nodemailer is a server-side module only, so you can't use that in your frontend.
use import as a function, something like this:

import('mailgun-js').then(mg => {
const mailgun = mg({apiKey: api_key, domain: domain})
/** do your stuff in here */
}

Regards
Sander
Reply all
Reply to author
Forward
0 new messages