0

I've just started to use Angular and I'm having trouble with running a working example of using the "emailjs" package in Angular 7 version. I was wondering if maybe someone could give me some guidance on how to get the implementation working? The test code of the call is the same as original at the source

BTW, despite the modification (source of the hint) on the surce at the "node_modules/@angular-devkit/build-angular/src/angular-cli-files/models/webpack-configs/browser.js" (change to "node: {crypto: true, stream: true} , "), I'am still getting errors:

*ERROR and ./node_modules/emailjs/smtp/message.js Module not found: Error: Can not resolve 'fs' in 'C: \ VSCodeProjects \ NAProject \ node_modules \ emailjs \ smtp'

ERROR and ./node_modules/emailjs/smtp/smtp.js Module not found: Error: Can not resolve 'net' and 'C: \ VSCodeProjects \ NAProject \ node_modules \ emailjs \ smtp'

ERROR and ./node_modules/emailjs/smtp/smtp.js Module not found: Error: Can not resolve 'os' in 'C: \ VSCodeProjects \ NAProject \ node_modules \ emailjs \ smtp'*

versions:

  • @ emailjs 2.2.0
  • @ npm 6.4.1
  • @ angular-devkit / architect 0.10.7
  • @ angular-devkit / build-angular 0.10.7
  • @ angular-devkit / build-optimizer 0.10.7
  • @ angular-devkit / build-webpack 0.10.7
  • @ angular-devkit / core 7.0.7
  • @ angular-devkit / schematics 7.3.0
  • @ angular / cli 7.3.0
  • @ ngtools / webpack 7.0.7
  • @ schematics / angular 7.3.0
  • @ schematics / update 0.13.0
  • rxjs 6.3.3 typescript 3.1.6
  • webpack 4.19.1

I would appreciate any help, regards, E.

1
  • That looks like a node package. Not a client side package. By node package I mean that it was intended to be ran on a server, not within a client side application like angular. Commented May 6, 2019 at 19:42

1 Answer 1

1

That package is a node package. Meaning that is was designed to run on a node.js server. You are trying to use it in your angular app which is why you get those errors.

The documentation states that it is intended for use on an stmp server. Your angular app runs in the browser, which is not a node server.

send emails, html and attachments (files, streams and strings) from node.js to any smtp server

works with SSL and TLS smtp servers

Take a look at their requirements: https://www.npmjs.com/package/emailjs

What I would do is move this node package to your node server and then create a service in your angular application to interface with it.

Red Flags All of these are nodejs modules. A client application cannot use them. You need to run them on a server

  • Error: Can not resolve 'os'
  • Error: Can not resolve 'net'
  • Error: Can not resolve 'fs'
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.