I am trying to create a form that sends an email via using a send grid module however it does not seem to be compatible with my web browser because I get this error :
"Failed to compile.
Module not found: Error: Can't resolve 'fs' in '/Users/parisvinuya/RARYA - GDSC WEBSITE/gdsc-website/main/node_modules/@sendgrid/helpers/classes' ERROR in ./node_modules/@sendgrid/helpers/classes/attachment.js 12:11-24 Module not found: Error: Can't resolve 'fs' in '/Users/parisvinuya/RARYA - GDSC WEBSITE/gdsc-website/main/node_modules/@sendgrid/helpers/classes'
ERROR in ./node_modules/@sendgrid/helpers/classes/attachment.js 14:13-28 Module not found: Error: Can't resolve 'path' in '/Users/parisvinuya/RARYA - GDSC WEBSITE/gdsc-website/main/node_modules/@sendgrid/helpers/classes'
BREAKING CHANGE: webpack < 5 used to include polyfills for node.js core modules by default. This is no longer the case. Verify if you need this module and configure a polyfill for it.
If you want to include a polyfill, you need to: - add a fallback 'resolve.fallback: { "path": require.resolve("path-browserify") }' - install 'path-browserify' If you don't want to include a polyfill, you can use an empty module like this: resolve.fallback: { "path": false }
webpack compiled with 2 errors"
Here is my code for indexfirebase.ts:
import * as sgMail from "@sendgrid/mail";
import { resolve, require } from "path-browserify";
sgMail.setApiKey(
"******"
);
const msg = {
to: "*****@gmail.com",
from: "[email protected]",
subject: "Example Subject",
text: "Example plain text content",
html: "<p>Example HTML content</p>",
};
sgMail
.send(msg)
.then(() => {
console.log("Email sent successfully");
})
.catch((error) => {
console.error(error.toString());
});
resolve.fallback = { path: require.resolve("path-browserify") };
The thing is, I already put "resolve.fallback = { path: require.resolve("path-browserify") };" in my code but it is still not working and I'm not sure why...