Next.js Discord

Discord Forum

'import', and 'export' cannot be used outside of module code

Unanswered
Ragdoll posted this in #help-forum
Open in Discord
RagdollOP
I am trying to use the library @electric-sql/pglite with nextjs but when try to build I get this error, the library is only esm and already minified.

If there any way to solve it? I try to add it to transpilePackages but doesnt work either

static/media/index.a7d43220.js from Terser
  x 'import', and 'export' cannot be used outside of module code
   ,-[1:1]
 1 | import { a, b, c, d, e, f } from "./chunk-OVRU7FYL.js";
   : ^^^^^^
 2 | import "./chunk-EKNQE2HU.js";
 3 | export { a as Mutex, d as PGlite, e as messages, c as parse, f as protocol, b as types }; //# sourceMappingURL=index.js.map
   `----

Caused by:
    0: failed to parse input file
    1: Syntax Error
Error:
  x 'import', and 'export' cannot be used outside of module code
   ,-[1:1]
 1 | import { a, b, c, d, e, f } from "./chunk-OVRU7FYL.js";
   : ^^^^^^
 2 | import "./chunk-EKNQE2HU.js";
 3 | export { a as Mutex, d as PGlite, e as messages, c as parse, f as protocol, b as types }; //# sourceMappingURL=index.js.map
   `----

Caused by:
    0: failed to parse input file
    1: Syntax Error


> Build failed because of webpack errors

0 Replies