standard-things / esm

Tomorrow's ECMAScript modules today!
Other
5.26k stars 147 forks source link

ERR_VM_DYNAMIC_IMPORT_CALLBACK_MISSING and next.js #908

Closed kevinsimper closed 1 year ago

kevinsimper commented 2 years ago

I am getting a ERR_VM_DYNAMIC_IMPORT_CALLBACK_MISSING error when using Nextjs 12.0.6

It fails in this file /node_modules/next/dist/server/config.js

On this line userConfigModule = await import((0, _url).pathToFileURL(path).href);

Unhandled Rejection at: Promise {
  <rejected> TypeError [ERR_VM_DYNAMIC_IMPORT_CALLBACK_MISSING]: A dynamic import callback was not specified.
      at new NodeError (node:internal/errors:371:5)
      at exports.importModuleDynamicallyCallback (node:internal/process/esm_loader:34:9)
      at Object.loadConfig [as default] (/Users/myproject/node_modules/next/dist/server/config.js:399:74)
      at async NextServer.loadConfig (/Users/myproject/node_modules/next/dist/server/next.js:116:22)
      at async NextServer.prepare (/Users/myproject/node_modules/next/dist/server/next.js:98:24) {
    code: 'ERR_VM_DYNAMIC_IMPORT_CALLBACK_MISSING'
  }
}

Not sure there is a good solution. A lot of things are going on and I think the solution is to keep it simpler. I just created this issue as other my have experienced, but there were no good results for this error. There is a lot of flux at the moment in the ES Modules system. Typescript also now support native esm modules and Next.js made its own swc rust transpiler.

kevinsimper commented 2 years ago

It is such a bizarre bug.

We were able to move off -r esm with this small proof of concept

kevinsimper/nextjs-prisma-typescript-custom-server

The missing link were how to run a shared