dword-design / nuxt-mail

Adds email sending capability to a Nuxt.js app. Adds a server route, an injected variable, and uses nodemailer to send emails.
Other
239 stars 18 forks source link

Nuxt3 - Unexpected token 'export' #137

Closed valentinMERCIER closed 1 year ago

valentinMERCIER commented 1 year ago

I have an issue when trying nuxt-mail with nuxt3

I've ran yarn add nuxt-mail

and then add the following config to my nuxt.config.ts file

modules : [
  ['nuxt-mail', {
    message: {
      to: 'me@gmail.com',
    },
    smtp: {
      host: 'smtp.mailtrap.io',
      port: 2525,
      auth: {
        user: 'username',
        pass: 'password'
      },
    },
  }],
]

I then encounter the following error

(node:71949) Warning: To load an ES module, set "type": "module" in the package.json or use the .mjs extension.
(Use `node --trace-warnings ...` to show where the warning was created)

 ERROR  [worker reload] [worker init] Unexpected token 'export'                            14:19:52

  export default {
  ^^^^^^

  SyntaxError: Unexpected token 'export'
  at internalCompileFunction (node:internal/vm:74:18)
  at wrapSafe (node:internal/modules/cjs/loader:1141:20)
  at Module._compile (node:internal/modules/cjs/loader:1182:27)
  at Module._extensions..js (node:internal/modules/cjs/loader:1272:10)
  at Module.load (node:internal/modules/cjs/loader:1081:32)
  at Module._load (node:internal/modules/cjs/loader:922:12)
  at ModuleWrap.<anonymous> (node:internal/modules/esm/translators:169:29)
  at ModuleJob.run (node:internal/modules/esm/module_job:194:25)

Anyone has encountered that error ?

patrikvadura commented 1 year ago

I have same problem, can anyone help?

(node:5125) Warning: To load an ES module, set "type": "module" in the package.json or use the .mjs extension.
(Use node --trace-warnings ... to show where the warning was created)

 ERROR  [worker reload] [worker init] Unexpected token 'export'                                                                                                                                                                                            11:14:30

  export default {
  ^^^^^^

  SyntaxError: Unexpected token 'export'
  at wrapSafe (internal/modules/cjs/loader.js:984:16)
  at Module._compile (internal/modules/cjs/loader.js:1032:27)
  at Object.Module._extensions..js (internal/modules/cjs/loader.js:1097:10)
  at Module.load (internal/modules/cjs/loader.js:933:32)
  at Function.Module._load (internal/modules/cjs/loader.js:774:14)
  at ModuleWrap.<anonymous> (internal/modules/esm/translators.js:199:29)
  at ModuleJob.run (internal/modules/esm/module_job.js:152:23)
  at async Loader.import (internal/modules/esm/loader.js:177:24)
  at async Object.loadESM (internal/process/esm_loader.js:68:5)
Tvkaes commented 1 year ago

same problem (node:7806) Warning: To load an ES module, set "type": "module" in the package.json or use the .mjs extension. (Usenode --trace-warnings ...` to show where the warning was created)

ERROR [worker reload] [worker init] Unexpected token 'export' 11:05:03

export default { ^^^^^^

SyntaxError: Unexpected token 'export' at Object.compileFunction (node:vm:352:18) at wrapSafe (node:internal/modules/cjs/loader:1032:15) at Module._compile (node:internal/modules/cjs/loader:1067:27) at Object.Module._extensions..js (node:internal/modules/cjs/loader:1155:10) at Module.load (node:internal/modules/cjs/loader:981:32) at Function.Module._load (node:internal/modules/cjs/loader:822:12) at ModuleWrap. (node:internal/modules/esm/translators:168:29) at ModuleJob.run (node:internal/modules/esm/module_job:195:25) at async Promise.all (index 0) at async ESMLoader.import (node:internal/modules/esm/loader:337:24) `

silverbackdan commented 1 year ago

Setting type to module does work, but it brings another issue.

You are using a plugin with legacy Nuxt 2 format (context, inject) which is likely to be broken.

In future they will be ignored so this module will need updating for this.

dword-design commented 1 year ago

Should be fixed.