I'm trying to send an email (a verification code), which should only happen in the server in convex
I've have used "use node" flag at the top of the file. and imported the package, in the convex env I added the envs as needed
Below is function
`export const sendMail = async ({ name, to, subject, body }: {
to: string,
name: string,
subject: string,
body: string,
}) => {
const { SMTP_EMAIL, SMTP_PASSWORD } = process.env;
node_modules/.pnpm/nodemailer@6.9.11/node_modules/nodemailer/lib/dkim/message-parser.js:3:26:
3 │ const Transform = require('stream').Transform;
╵ ~~~~~~~~
The package "stream" wasn't found on the file system but is built
into node. Are you trying to bundle for node? You can use
"platform: 'node'" to do that, which will remove this error.
X [ERROR] Could not resolve "crypto"
node_modules/.pnpm/nodemailer@6.9.11/node_modules/nodemailer/lib/dkim/sign.js:5:23:
5 │ const crypto = require('crypto');
╵ ~~~~~~~~
The package "crypto" wasn't found on the file system but is built
into node. Are you trying to bundle for node? You can use
"platform: 'node'" to do that, which will remove this error.
removing the function body even with the import inplace, convex compile just fine, what am I missing or doing wrong?
NOTE: Other packages works just fine like svix and bcrypt-ts
It looks like you are importing this file from one which does not have "use node", these are bundler errors saying these Node.js builtins can't be bundled.
I'm trying to send an email (a verification code), which should only happen in the server in convex I've have used "use node" flag at the top of the file. and imported the package, in the convex env I added the envs as needed Below is function `export const sendMail = async ({ name, to, subject, body }: { to: string, name: string, subject: string, body: string, }) => { const { SMTP_EMAIL, SMTP_PASSWORD } = process.env;
}`
but
npx convex dev
fails with errors:removing the function body even with the import inplace, convex compile just fine, what am I missing or doing wrong?
NOTE: Other packages works just fine like
svix
andbcrypt-ts