Sendgrid-nodejs: Can't resolve 'fs' in '@sendgrid\helpers\classes'

Created on 9 Jul 2019  路  7Comments  路  Source: sendgrid/sendgrid-nodejs

Issue Summary

Fresh install trying to use @sendgrid/mail - getting this error.

Steps to Reproduce

  1. npm install --save @sendgrid/mail
  2. Run project

Technical details:

  • sendgrid-nodejs Version: 0.1.0-2
  • Node.js Version: 10.15.1
question

Most helpful comment

I figured out ... you have to use SendGrid in your backend, not in your frontend. Install this library in your backend service, make the call from your frontend to initiate the backend. the 'fs' library will not work on the frontend.

All 7 comments

Same Here 馃槙
image

I am experiencing the same error. Has anyone found a solution or a workaround in the short term?
Screen Shot 2019-07-23 at 11 32 08 AM

_Note:_ Module not found: Error: Can't resolve 'fs' in '<my-path>/node_modules/@sendgrid/helpers/classes'

Seems like Issue #955 is related.

I found this Lil workaround, set in webpack config:

 node: {
      net: 'empty',      
      fs: 'empty',
      tls: 'empty'
}

@nephlin7 thanks for the workaround!
what should be done if my project does not have a webpack config? can this go in the tsconfig?

Anyone have an answer in case I don't have a webpack config?

I figured out ... you have to use SendGrid in your backend, not in your frontend. Install this library in your backend service, make the call from your frontend to initiate the backend. the 'fs' library will not work on the frontend.

Those are backend dependencies. It's you're using webpack for a backend service, you'll need to add this to your webpack config: target: 'node'

Was this page helpful?
0 / 5 - 0 ratings

Related issues

thinkingserious picture thinkingserious  路  4Comments

thidasapankaja picture thidasapankaja  路  4Comments

danielflippance picture danielflippance  路  4Comments

prasoonjalan picture prasoonjalan  路  3Comments

TobiahRex picture TobiahRex  路  3Comments