Error: Cannot find module '@netlify/emails' with Nuxt when calling the send email function

Hi, I’m using the new @netlify/emails plugin with Nuxt, which works correctly on development. The deployment goes through perfectly, but when the function is invoked I get the following error on its log:

It seems that it cannot find the plugin :confused:

Feb 18, 01:37:55 PM: 24b47f0b 2023-02-18T10:37:55.678Z	undefined	ERROR	Uncaught Exception 	{"errorType":"Runtime.ImportModuleError","errorMessage":"Error: Cannot find module '@netlify/emails'\nRequire stack:\n- /var/task/functions/email-send.js\n- /var/task/email-send.js\n- /var/runtime/index.mjs","stack":["Runtime.ImportModuleError: Error: Cannot find module '@netlify/emails'","Require stack:","- /var/task/functions/email-send.js","- /var/task/email-send.js","- /var/runtime/index.mjs","    at _loadUserApp (file:///var/runtime/index.mjs:1000:17)","    at async Object.UserFunction.js.module.exports.load (file:///var/runtime/index.mjs:1035:21)","    at async start (file:///var/runtime/index.mjs:1200:23)","    at async file:///var/runtime/index.mjs:1206:1"]}Feb 18, 01:37:55 PM: 24b47f0b 2023-02-18T10:37:55.891Z	undefined	ERROR	Uncaught Exception 	{"errorType":"Runtime.ImportModuleError","errorMessage":"Error: Cannot find module '@netlify/emails'\nRequire stack:\n- /var/task/functions/email-send.js\n- /var/task/email-send.js\n- /var/runtime/index.mjs","stack":["Runtime.ImportModuleError: Error: Cannot find module '@netlify/emails'","Require stack:","- /var/task/functions/email-send.js","- /var/task/email-send.js","- /var/runtime/index.mjs","    at _loadUserApp (file:///var/runtime/index.mjs:1000:17)","    at async Object.UserFunction.js.module.exports.load (file:///var/runtime/index.mjs:1035:21)","    at async start (file:///var/runtime/index.mjs:1200:23)","    at async file:///var/runtime/index.mjs:1206:1"]}Feb 18, 01:37:55 PM: 24b47f0b Unknown application error occurredFeb 18, 01:37:55 PM: 24b47f0b Runtime.ImportModuleErrorFeb 18, 01:37:55 PM: 24b47f0b Duration: 176.51 ms	Memory Usage: 12 MB	

Here is the build log:

1:34:09 PM: build-image version: 5b0ab77c5e46895703390c45e86a907d4b78547b (focal)
1:34:09 PM: buildbot version: 5b0ab77c5e46895703390c45e86a907d4b78547b
1:34:10 PM: Fetching cached dependencies
1:34:10 PM: Starting to download cache of 161.9MB
1:34:10 PM: Finished downloading cache in 708ms
1:34:10 PM: Starting to extract cache
1:34:12 PM: Finished extracting cache in 1.658s
1:34:12 PM: Finished fetching cache in 2.422s
1:34:12 PM: Starting to prepare the repo for build
1:34:12 PM: Preparing Git Reference refs/heads/sandbox
1:34:13 PM: Parsing package.json dependencies
1:34:14 PM: ​❯ Initial build environmentbaseRelDir: truebranch: sandboxcontext: productioncwd: /opt/build/repofeatureFlags: []mode: buildbotrepositoryRoot: /opt/build/repositeId: 70430f1b-35a4-43a8-a6b1-2e4eb6d8244e​❯ UI build settingsbaseRelDir: truebuild:  command: npm run generate  environment:    - DSC_PK    - DSC_PUBLIC    - DSC_ROOM_ID    - NETLIFY_BUILD_DEBUG    - NETLIFY_EMAILS_DIRECTORY    - NETLIFY_EMAILS_MAILGUN_DOMAIN    - NETLIFY_EMAILS_MAILGUN_HOST_REGION    - NETLIFY_EMAILS_PROVIDER    - NETLIFY_EMAILS_PROVIDER_API_KEY    - NETLIFY_EMAILS_SECRET    - NETLIFY_GRAPH_TOKEN    - NODE_VERSION    - ONEGRAPH_AUTHLIFY_TOKEN    - STRIPE_SK    - TALKJS_APP_ID    - TALKJS_SECRET_KEY  publish: distplugins:  - inputs: {}    package: '@netlify/plugin-emails'​❯ Resolved build environmentbranch: sandboxbuildDir: /opt/build/repoconfigPath: /opt/build/repo/netlify.tomlcontext: productionenv: []​❯ Resolved configbuild:  command: npm run generate  commandOrigin: ui  environment:    - DSC_PK    - DSC_PUBLIC    - DSC_ROOM_ID    - NETLIFY_BUILD_DEBUG    - NETLIFY_EMAILS_DIRECTORY    - NETLIFY_EMAILS_MAILGUN_DOMAIN    - NETLIFY_EMAILS_MAILGUN_HOST_REGION    - NETLIFY_EMAILS_PROVIDER    - NETLIFY_EMAILS_PROVIDER_API_KEY    - NETLIFY_EMAILS_SECRET    - NETLIFY_GRAPH_TOKEN    - NODE_VERSION    - ONEGRAPH_AUTHLIFY_TOKEN    - STRIPE_SK    - TALKJS_APP_ID    - TALKJS_SECRET_KEY  publish: /opt/build/repo/dist  publishOrigin: uifunctions:  firebase-user-claims:    included_files:      - ./cert.jsonfunctionsDirectory: /opt/build/repo/functionsplugins:  - inputs: {}    origin: config    package: '@netlify/plugin-emails'
1:34:14 PM: Starting build script
1:34:14 PM: Installing dependencies
1:34:14 PM: Python version set to 2.7
1:34:15 PM: Started restoring cached Node.js version
1:34:15 PM: Finished restoring cached Node.js version
1:34:15 PM: Downloading and installing node v16.16.0...
1:34:16 PM: Downloading https://nodejs.org/dist/v16.16.0/node-v16.16.0-linux-x64.tar.xz...
1:34:16 PM: Computing checksum with sha256sum
1:34:16 PM: Checksums matched!
1:34:18 PM: Now using node v16.16.0 (npm v8.11.0)
1:34:18 PM: Enabling Node.js Corepack
1:34:18 PM: Started restoring cached build plugins
1:34:18 PM: Finished restoring cached build plugins
1:34:18 PM: Attempting Ruby version 2.7.2, read from environment
1:34:18 PM: Using Ruby version 2.7.2
1:34:19 PM: Using PHP version 8.0
1:34:19 PM: Started restoring cached corepack dependencies
1:34:19 PM: Finished restoring cached corepack dependencies
1:34:19 PM: No npm workspaces detected
1:34:19 PM: Started restoring cached node modules
1:34:19 PM: Finished restoring cached node modules
1:34:19 PM: Installing npm packages using npm version 8.11.0
1:34:23 PM: npm WARN deprecated @npmcli/move-file@2.0.1: This functionality has been moved to @npmcli/fs
1:34:25 PM: npm WARN deprecated @npmcli/move-file@1.1.2: This functionality has been moved to @npmcli/fs
1:34:25 PM: npm WARN deprecated @npmcli/move-file@1.1.2: This functionality has been moved to @npmcli/fs
1:34:29 PM: added 237 packages, removed 360 packages, changed 271 packages, and audited 1684 packages in 10s
1:34:29 PM: 208 packages are looking for funding
1:34:29 PM:   run `npm fund` for details
1:34:29 PM: 13 vulnerabilities (1 moderate, 12 high)
1:34:29 PM: To address issues that do not require attention, run:
1:34:29 PM:   npm audit fix
1:34:29 PM: To address all issues (including breaking changes), run:
1:34:29 PM:   npm audit fix --force
1:34:29 PM: Run `npm audit` for details.
1:34:29 PM: npm packages installed
1:34:29 PM: Started restoring cached go cache
1:34:29 PM: Finished restoring cached go cache
1:34:29 PM: Installing Go version 1.17 (requested 1.17)
1:34:33 PM: go version go1.17 linux/amd64
1:34:33 PM: Detected 1 framework(s)
1:34:33 PM: "nuxt" at version "2.16.1"
1:34:33 PM: Installing missing commands
1:34:33 PM: Verify run directory
1:34:33 PM: Section completed: initializing
1:34:35 PM: ​
1:34:35 PM:   Netlify Build                                                 
1:34:35 PM: ────────────────────────────────────────────────────────────────
1:34:35 PM: ​
1:34:35 PM: ❯ Version
1:34:35 PM:   @netlify/build 29.5.7
1:34:35 PM: ​
1:34:35 PM: ❯ Flags
1:34:35 PM:   apiHost: api.netlify.com
1:34:35 PM:   baseRelDir: true
1:34:35 PM:   branch: sandbox
1:34:35 PM:   buildId: 63f0a9a0a4b65d000819133a
1:34:35 PM:   buildbotServerSocket: /tmp/netlify-buildbot-socket
1:34:35 PM:   cacheDir: /opt/build/cache
1:34:35 PM:   cachedConfigPath: /tmp/netlify_config.json
1:34:35 PM:   context: production
1:34:35 PM:   cwd: /opt/build/repo
1:34:35 PM:   deployId: 63f0a9a0a4b65d000819133c
1:34:35 PM:   edgeFunctionsDistDir: /tmp/edge-63f0a9a0a4b65d000819133c
1:34:35 PM:   featureFlags:
1:34:35 PM:     - edge_functions_cache_cli
1:34:35 PM:     - edge_functions_system_logger
1:34:35 PM:   framework: nuxt
1:34:35 PM:   functionsDistDir: /tmp/zisi-63f0a9a0a4b65d000819133c
1:34:35 PM:   mode: buildbot
1:34:35 PM:   nodePath: /opt/buildhome/.nvm/versions/node/v16.16.0/bin/node
1:34:35 PM:   repositoryRoot: /opt/build/repo
1:34:35 PM:   saveConfig: true
1:34:35 PM:   sendStatus: true
1:34:35 PM:   siteId: 70430f1b-35a4-43a8-a6b1-2e4eb6d8244e
1:34:35 PM:   statsd:
1:34:35 PM:     host: 10.65.158.53
1:34:35 PM:     port: 8125
1:34:35 PM:   systemLogFile: 3
1:34:35 PM:   testOpts:
1:34:35 PM:     silentLingeringProcesses: ''
1:34:35 PM: ​
1:34:35 PM: ❯ Current directory
1:34:35 PM:   /opt/build/repo
1:34:35 PM: ​
1:34:35 PM: ❯ Config file
1:34:35 PM:   /opt/build/repo/netlify.toml
1:34:35 PM: ​
1:34:35 PM: ❯ Resolved config
1:34:35 PM:   build:
1:34:35 PM:     command: npm run generate
1:34:35 PM:     commandOrigin: ui
1:34:35 PM:     environment:
1:34:35 PM:       - DSC_PK
1:34:35 PM:       - DSC_PUBLIC
1:34:35 PM:       - DSC_ROOM_ID
1:34:35 PM:       - NETLIFY_BUILD_DEBUG
1:34:35 PM:       - NETLIFY_EMAILS_DIRECTORY
1:34:35 PM:       - NETLIFY_EMAILS_MAILGUN_DOMAIN
1:34:35 PM:       - NETLIFY_EMAILS_MAILGUN_HOST_REGION
1:34:35 PM:       - NETLIFY_EMAILS_PROVIDER
1:34:35 PM:       - NETLIFY_EMAILS_PROVIDER_API_KEY
1:34:35 PM:       - NETLIFY_EMAILS_SECRET
1:34:35 PM:       - NETLIFY_GRAPH_TOKEN
1:34:35 PM:       - NODE_VERSION
1:34:35 PM:       - ONEGRAPH_AUTHLIFY_TOKEN
1:34:35 PM:       - STRIPE_SK
1:34:35 PM:       - TALKJS_APP_ID
1:34:35 PM:       - TALKJS_SECRET_KEY
1:34:35 PM:     publish: /opt/build/repo/dist
1:34:35 PM:     publishOrigin: ui
1:34:35 PM:   functions:
1:34:35 PM:     firebase-user-claims:
1:34:35 PM:       included_files:
1:34:35 PM:         - ./cert.json
1:34:35 PM:   functionsDirectory: /opt/build/repo/functions
1:34:35 PM:   plugins:
1:34:35 PM:     - inputs: {}
1:34:35 PM:       origin: config
1:34:35 PM:       package: '@netlify/plugin-emails'
1:34:35 PM: ​
1:34:35 PM: ❯ Context
1:34:35 PM:   production
1:34:35 PM: ​
1:34:35 PM: ❯ Available plugins
1:34:35 PM:    - @algolia/netlify-plugin-crawler@1.0.0
1:34:35 PM:    - @bharathvaj/netlify-plugin-airbrake@1.0.2
1:34:35 PM:    - @chiselstrike/netlify-plugin@0.1.0
1:34:35 PM:    - @commandbar/netlify-plugin-commandbar@0.0.4
1:34:35 PM:    - @helloample/netlify-plugin-replace@1.1.4
1:34:35 PM:    - @netlify/feature-package-pilot@0.1.11
1:34:35 PM:    - @netlify/plugin-angular-universal@1.0.1
1:34:35 PM:    - @netlify/plugin-emails@1.0.0
1:34:35 PM:    - @netlify/plugin-gatsby@3.5.1
1:34:35 PM:    - @netlify/plugin-lighthouse@4.0.7
1:34:35 PM:    - @netlify/plugin-nextjs@4.30.4
1:34:35 PM:    - @netlify/plugin-sitemap@0.8.1
1:34:35 PM:    - @newrelic/netlify-plugin@1.0.1
1:34:35 PM:    - @sentry/netlify-build-plugin@1.1.1
1:34:35 PM:    - @snaplet/netlify-preview-database-plugin@2.0.0
1:34:35 PM:    - @takeshape/netlify-plugin-takeshape@1.0.0
1:34:35 PM:    - @vgs/netlify-plugin-vgs@0.0.2
1:34:35 PM:    - netlify-build-plugin-dareboost@1.2.1
1:34:35 PM:    - netlify-build-plugin-debugbear@1.0.6
1:34:35 PM:    - netlify-build-plugin-perfbeacon@1.0.3
1:34:35 PM:    - netlify-build-plugin-speedcurve@2.0.0
1:34:35 PM:    - netlify-deployment-hours-plugin@0.0.10
1:34:35 PM:    - netlify-plugin-a11y@0.0.12
1:34:35 PM:    - netlify-plugin-add-instagram@0.2.2
1:34:35 PM:    - netlify-plugin-algolia-index@0.3.0
1:34:35 PM:    - netlify-plugin-amp-server-side-rendering@1.0.2
1:34:35 PM:    - netlify-plugin-brand-guardian@1.0.1
1:34:35 PM:    - netlify-plugin-build-logger@1.0.3
1:34:35 PM:    - netlify-plugin-cache-nextjs@1.4.0
1:34:35 PM:    - netlify-plugin-cecil-cache@0.3.3
1:34:35 PM:    - netlify-plugin-checklinks@4.1.1
1:34:35 PM:    - netlify-plugin-chromium@1.1.4
1:34:35 PM:    - netlify-plugin-cloudinary@1.0.3
1:34:35 PM:    - netlify-plugin-contextual-env@0.3.0
1:34:35 PM:    - netlify-plugin-cypress@2.2.0
1:34:35 PM:    - netlify-plugin-debug-cache@1.0.4
1:34:35 PM:    - netlify-plugin-encrypted-files@0.0.5
1:34:35 PM:    - netlify-plugin-fetch-feeds@0.2.3
1:34:35 PM:    - netlify-plugin-flutter@1.1.0
1:34:35 PM:    - netlify-plugin-formspree@1.0.1
1:34:35 PM:    - netlify-plugin-gatsby-cache@0.3.0
1:34:35 PM:    - netlify-plugin-get-env-vars@1.0.0
1:34:35 PM:    - netlify-plugin-ghost-inspector@1.0.1
1:34:35 PM:    - netlify-plugin-ghost-markdown@3.1.0
1:34:35 PM:    - netlify-plugin-gmail@1.1.0
1:34:35 PM:    - netlify-plugin-gridsome-cache@1.0.3
1:34:35 PM:    - netlify-plugin-hashfiles@4.0.2
1:34:35 PM:    - netlify-plugin-html-validate@1.0.0
1:34:35 PM:    - netlify-plugin-hugo-cache-resources@0.2.1
1:34:35 PM:    - netlify-plugin-image-optim@0.4.0
1:34:35 PM:    - netlify-plugin-inline-critical-css@2.0.0
1:34:35 PM:    - netlify-plugin-inline-functions-env@1.0.8
1:34:35 PM:    - netlify-plugin-inline-source@1.0.4
1:34:35 PM:    - netlify-plugin-inngest@1.0.0
1:34:35 PM:    - netlify-plugin-is-website-vulnerable@2.0.3
1:34:35 PM:    - netlify-plugin-jekyll-cache@1.0.0
1:34:35 PM:    - netlify-plugin-js-obfuscator@1.0.20
1:34:35 PM:    - netlify-plugin-minify-html@0.3.1
1:34:35 PM:    - netlify-plugin-next-dynamic@1.0.9
1:34:35 PM:    - netlify-plugin-nimbella@2.1.0
1:34:35 PM:    - netlify-plugin-no-more-404@0.0.15
1:34:35 PM:    - netlify-plugin-nx-skip-build@0.0.7
1:34:35 PM:    - netlify-plugin-pagewatch@1.0.4
1:34:35 PM:    - netlify-plugin-playwright-cache@0.0.1
1:34:35 PM:    - netlify-plugin-prerender-spa@1.0.1
1:34:35 PM:    - netlify-plugin-prisma-provider@0.3.0
1:34:35 PM:    - netlify-plugin-pushover@0.1.1
1:34:35 PM:    - netlify-plugin-qawolf@1.2.0
1:34:35 PM:    - netlify-plugin-rss@0.0.8
1:34:35 PM:    - netlify-plugin-search-index@0.1.5
1:34:35 PM:    - netlify-plugin-snyk@1.2.0
1:34:35 PM:    - netlify-plugin-stepzen@1.0.4
1:34:35 PM:    - netlify-plugin-subfont@6.0.0
1:34:35 PM:    - netlify-plugin-submit-sitemap@0.4.0
1:34:35 PM:    - netlify-plugin-to-all-events@1.3.1
1:34:35 PM:    - netlify-plugin-use-env-in-runtime@1.2.1
1:34:35 PM:    - netlify-plugin-visual-diff@2.0.0
1:34:35 PM:    - netlify-plugin-webmentions@1.1.0
1:34:35 PM:    - netlify-purge-cloudflare-on-deploy@1.2.0
1:34:35 PM: ​
1:34:35 PM: ❯ Loading plugins
1:34:35 PM:    - @netlify/plugin-emails@1.0.0 from netlify.toml (pinned 1, latest 1.0.0, expected 1.0.0, compatible 1.0.0)
1:34:36 PM: ​
1:34:36 PM:   1. @netlify/plugin-emails (onPreBuild event)                  
1:34:36 PM: ────────────────────────────────────────────────────────────────
1:34:36 PM: ​
1:34:36 PM: Step starting.
1:34:36 PM: Step started.
1:34:36 PM: Plugin logic started.
1:34:36 PM: Plugin logic ended.
1:34:36 PM: Stop closing.
1:34:36 PM: Step ended.
1:34:36 PM: Netlify configuration property "functions.emails" value changed to {
1:34:36 PM:   included_files: [ './emails/**' ],
1:34:36 PM:   external_node_modules: [ 'node-fetch@2' ]
1:34:36 PM: }.
1:34:36 PM: ​
1:34:36 PM: ❯ Updated config
1:34:36 PM:   build:
1:34:36 PM:     command: npm run generate
1:34:36 PM:     commandOrigin: ui
1:34:36 PM:     environment:
1:34:36 PM:       - DSC_PK
1:34:36 PM:       - DSC_PUBLIC
1:34:36 PM:       - DSC_ROOM_ID
1:34:36 PM:       - NETLIFY_BUILD_DEBUG
1:34:36 PM:       - NETLIFY_EMAILS_DIRECTORY
1:34:36 PM:       - NETLIFY_EMAILS_MAILGUN_DOMAIN
1:34:36 PM:       - NETLIFY_EMAILS_MAILGUN_HOST_REGION
1:34:36 PM:       - NETLIFY_EMAILS_PROVIDER
1:34:36 PM:       - NETLIFY_EMAILS_PROVIDER_API_KEY
1:34:36 PM:       - NETLIFY_EMAILS_SECRET
1:34:36 PM:       - NETLIFY_GRAPH_TOKEN
1:34:36 PM:       - NODE_VERSION
1:34:36 PM:       - ONEGRAPH_AUTHLIFY_TOKEN
1:34:36 PM:       - STRIPE_SK
1:34:36 PM:       - TALKJS_APP_ID
1:34:36 PM:       - TALKJS_SECRET_KEY
1:34:36 PM:     publish: /opt/build/repo/dist
1:34:36 PM:     publishOrigin: ui
1:34:36 PM:   functions:
1:34:36 PM:     emails:
1:34:36 PM:       external_node_modules:
1:34:36 PM:         - node-fetch@2
1:34:36 PM:       included_files:
1:34:36 PM:         - ./emails/**    firebase-user-claims:      included_files:        - ./cert.json  functionsDirectory: /opt/build/repo/functions  plugins:    - inputs: {}      origin: config      package: '@netlify/plugin-emails'Step completed.
1:34:36 PM: ​
1:34:36 PM: (@netlify/plugin-emails onPreBuild completed in 23ms)
1:34:36 PM: Build step duration: @netlify/plugin-emails onPreBuild completed in 23ms
1:34:36 PM: ​
1:34:36 PM:   2. Build command from Netlify app                             
1:34:36 PM: ────────────────────────────────────────────────────────────────
1:34:36 PM: ​
1:34:36 PM: $ npm run generate
1:34:36 PM: > tramifacil@1.0.0 generate
1:34:36 PM: > nuxt generate
1:34:55 PM: ​
1:34:55 PM: (build.command completed in 19.3s)
1:34:55 PM: Build step duration: build.command completed in 19301ms
1:34:55 PM: ​
1:34:55 PM:   3. Functions bundling                                         
1:34:55 PM: ────────────────────────────────────────────────────────────────
1:34:55 PM: ​
1:34:55 PM: Packaging Functions from .netlify/functions-internal directory:
1:34:55 PM:  - emails/index.ts
1:34:55 PM: ​
1:34:55 PM: Packaging Functions from functions directory:
1:34:55 PM:  - email-send.js
1:34:55 PM:  - stripe-prod-price-read.js
1:34:55 PM:  - stripe-product-create.js
1:34:55 PM:  - stripe-sessions-assessment-create.js
1:34:55 PM:  - stripe-sessions-create.js
1:34:55 PM:  - talkjs-conversation-create.js
1:34:55 PM:  - talkjs-user-conversations.js
1:34:55 PM:  - talkjs-user-create.js
1:34:55 PM:  - talkjs-user-read.js
1:34:55 PM:  - firebase-user-claims/firebase-user-claims.js
1:34:55 PM: ​
1:35:00 PM: ​
1:35:00 PM: (Functions bundling completed in 4.1s)
1:35:00 PM: Build step duration: Functions bundling completed in 4195ms
1:35:00 PM: ​
1:35:00 PM:   4. Deploy site                                                
1:35:00 PM: ────────────────────────────────────────────────────────────────
1:35:00 PM: ​
1:35:00 PM: ​
1:35:00 PM: ❯ Uploaded config
1:35:00 PM:   [functions]
1:35:00 PM: ​
1:35:00 PM:     [functions.firebase-user-claims]
1:35:00 PM:     included_files = [
1:35:00 PM:       "./cert.json"
1:35:00 PM:     ]
1:35:00 PM: ​
1:35:00 PM:     [functions.emails]
1:35:00 PM:     included_files = [
1:35:00 PM:       "./emails/**"
1:35:00 PM:     ]
1:35:00 PM:     external_node_modules = [
1:35:00 PM:       "node-fetch@2"
1:35:00 PM:     ]
1:35:00 PM: ​
1:35:00 PM:   [[plugins]]
1:35:00 PM:   package = "@netlify/plugin-emails"
1:35:00 PM: ​
1:35:00 PM:   [context]
1:35:00 PM: ​
1:35:00 PM:     [context.production]
1:35:00 PM: ​
1:35:00 PM:       [context.production.functions]
1:35:00 PM: ​
1:35:00 PM:         [context.production.functions.emails]
1:35:00 PM:         included_files = [
1:35:00 PM:           "./emails/**"
1:35:00 PM:         ]
1:35:00 PM:         external_node_modules = [
1:35:00 PM:           "node-fetch@2"
1:35:00 PM:         ]
1:35:00 PM: ​
1:35:00 PM:     [context.sandbox]
1:35:00 PM: ​
1:35:00 PM:       [context.sandbox.functions]
1:35:00 PM: ​
1:35:00 PM:         [context.sandbox.functions.emails]
1:35:00 PM:         included_files = [
1:35:00 PM:           "./emails/**"
1:35:00 PM:         ]
1:35:00 PM:         external_node_modules = [
1:35:00 PM:           "node-fetch@2"
1:35:00 PM:         ]
1:35:00 PM: ​
1:35:00 PM: ❯ Uploaded headers
1:35:00 PM:   No headers
1:35:00 PM: ​
1:35:00 PM: ❯ Uploaded redirects
1:35:00 PM:   No redirects
1:35:00 PM: ​
1:35:00 PM: Starting to deploy site from 'dist'
1:35:00 PM: Calculating files to upload
1:35:00 PM: 60 new files to upload
1:35:00 PM: 11 new functions to upload
1:35:09 PM: Section completed: deploying
1:35:09 PM: Site deploy was successfully initiated
1:35:09 PM: ​
1:35:09 PM: (Deploy site completed in 9.7s)
1:35:09 PM: Build step duration: Deploy site completed in 9761ms
1:35:09 PM: Starting post processing
1:35:09 PM: ​
1:35:09 PM:   Netlify Build Complete                                        
1:35:09 PM: ────────────────────────────────────────────────────────────────
1:35:10 PM: Post processing - HTML
1:35:09 PM: ​
1:35:09 PM: (Netlify Build completed in 34.7s)
1:35:09 PM: Build step duration: Netlify Build completed in 34730ms
1:35:10 PM: Caching artifacts
1:35:10 PM: Started saving node modules
1:35:10 PM: Finished saving node modules
1:35:10 PM: Started saving build plugins
1:35:10 PM: Post processing - header rules
1:35:10 PM: Finished saving build plugins
1:35:10 PM: Started saving corepack cache
1:35:10 PM: Finished saving corepack cache
1:35:10 PM: Post processing - redirect rules
1:35:10 PM: Started saving pip cache
1:35:10 PM: Finished saving pip cache
1:35:10 PM: Started saving emacs cask dependencies
1:35:10 PM: Post processing done
1:35:10 PM: Finished saving emacs cask dependencies
1:35:10 PM: Started saving maven dependencies
1:35:10 PM: Finished saving maven dependencies
1:35:10 PM: Started saving boot dependencies
1:35:10 PM: Section completed: postprocessing
1:35:10 PM: Finished saving boot dependencies
1:35:10 PM: Started saving rust rustup cache
1:35:10 PM: Finished saving rust rustup cache
1:35:10 PM: Started saving go dependencies
1:35:10 PM: Finished saving go dependencies
1:35:11 PM: Build script success
1:35:11 PM: Section completed: building
1:35:11 PM: Site is live ✨
1:35:12 PM: Uploading Cache of size 192.2MB
1:35:13 PM: Section completed: cleanup
1:35:13 PM: Finished processing build request in 1m3.885s

Is it a current issue?

And here is the function code:

"use strict";
import { sendEmail } from "@netlify/emails";

module.exports.handler = async (event) => {
  try {
    const payload = JSON.parse(event.body);
    console.log({ payload });
    await sendEmail({
      from: "<HERE I HAVE MY EMAIL>",
      to: payload.to,
      subject: payload.subject,
      template: payload.template,
      parameters: {
        ...payload
      },
    });
    return {
      success: true,
      statusCode: 200,
      body: JSON.stringify({
        success: true,
      }),
      error: null,
    };
  } catch (error) {
    console.error({ error });
    return {
      success: false,
      statusCode: 500,
      body: JSON.stringify({
        success: false,
      }),
      error,
    };
  }
};

Hey @sgaconsultores,

We’ve posted this for our devs to take a look and advise as soon as possible.

1 Like

Thanks for the quick response @hrishikesh :+1:t4:

Hi @sgaconsultores, I just want to double check that you have run npm install @netlify/emails. This is a standalone package and not the plugin itself, so requires installing onto the project.

Hi, I finally made it work @thorleylt :rocket:, I will show what I did:

So first, you do have to run the installation:

npm install @netlify/emails

I call my function with the next payload from my vuex store (On parameters I just add any JSON with the dynamic information needed on the email):

export const actions = {
  async sendEmail({ commit },payload) {
    try {
      const emailPayload = {
        to: payload.to,
        subject: payload.subject,
        template: payload.template,
        parameters: {
          ...payload.parameters
        },
      }
      await this.$axios.$post('./.netlify/functions/email-send',emailPayload)
    } catch (error) {
      console.error(error);
    }
  }
}

My sending email function looks like this

import { sendEmail } from "@netlify/emails";
module.exports.handler = async (event) => {
  try {
    const payload = JSON.parse(event.body);
    console.log({ payload });
    await sendEmail({
      from: "<YOUR EMAIL WITH A VERIFIED MAILGUN DOMAIN GOES HERE>",
      ...payload
    });
    return {
      success: true,
      statusCode: 200,
      body: JSON.stringify({
        success: true,
      }),
      error: null,
    };
  } catch (error) {
    console.error({ error });
    return {
      success: false,
      statusCode: 500,
      body: JSON.stringify({
        success: false,
      }),
      error,
    };
  }
};

And on the netlify.toml configuration you need to add this:

[functions]
  node_bundler = "esbuild"

Hope this helps anyone out there :+1:t4:

Hi :wave:t6: @sgaconsultores thank you so much for sharing your solution! This will help other community members!