N
Nuxt8mo ago
Usagi Love

Issues with Amplify DataStore Unexpected token 'export'

Losing my mind over this issue, I'm using Amplify v6 with Nuxt3 and using amplify codegen models it creates models to use with the datastore. however importing these will result in an error.
ERROR [worker reload] [worker init] Unexpected token 'export' 8:10:41 AM

export * from './builder';
^^^^^^

SyntaxError: Unexpected token 'export'
at internalCompileFunction (node:internal/vm:128:18)
at wrapSafe (node:internal/modules/cjs/loader:1280:20)
at Module._compile (node:internal/modules/cjs/loader:1332:27)
at Object..js (node:internal/modules/cjs/loader:1427:10)
at Module.load (node:internal/modules/cjs/loader:1206:32)
at Function._load (node:internal/modules/cjs/loader:1022:12)
at Module.require (node:internal/modules/cjs/loader:1231:19)
at require (node:internal/modules/helpers:179:18)
at Object.<anonymous> (node_modules/@aws-amplify/data-schema/src/runtime/client/index.ts:14:27)
at Module._compile (node:internal/modules/cjs/loader:1369:14)
ERROR [worker reload] [worker init] Unexpected token 'export' 8:10:41 AM

export * from './builder';
^^^^^^

SyntaxError: Unexpected token 'export'
at internalCompileFunction (node:internal/vm:128:18)
at wrapSafe (node:internal/modules/cjs/loader:1280:20)
at Module._compile (node:internal/modules/cjs/loader:1332:27)
at Object..js (node:internal/modules/cjs/loader:1427:10)
at Module.load (node:internal/modules/cjs/loader:1206:32)
at Function._load (node:internal/modules/cjs/loader:1022:12)
at Module.require (node:internal/modules/cjs/loader:1231:19)
at require (node:internal/modules/helpers:179:18)
at Object.<anonymous> (node_modules/@aws-amplify/data-schema/src/runtime/client/index.ts:14:27)
at Module._compile (node:internal/modules/cjs/loader:1369:14)
I tried on Windows and Linux(WSL)/Docker and all give this error. I also tried with just a pure Vite + Vue app and it works as normal so there has to be something wrong with Nuxt If someone has experience with DataStores/Amplify that would be highly appreciated.
import {Song, PlaylistSong} from "~/src/models/index.js";
import {DataStore} from "@aws-amplify/datastore";
import {Song, PlaylistSong} from "~/src/models/index.js";
import {DataStore} from "@aws-amplify/datastore";
this is the code that causes it.
1 Reply
Usagi Love
Usagi LoveOP8mo ago
even just using import {DataStore} from "@aws-amplify/datastore"; will result in the same error
Want results from more Discord servers?
Add your server