2

I'm working on a tiny next.js project, but the issue that i'm facing is that ES6 module import only works in React components.The 2 following code are some Database configurations that are used in routes inside API folder. The code below is the one that doesn't work using ES6 modules Code with ES6 module system

Here is the code that works fine with common js Code using common JS

Also when i use the debugger, with the code using ES6 modules, i cannot capture values form imported modules and i only capture values when using common js.

I've tried to solve the problem with this github issue : Support ES module in next.config.js but id did not help. Have any idea?

Christian Lisangola
  • 2,128
  • 3
  • 12
  • 26

1 Answers1

0

ES6 imports does not working because this is server side rendering.

I advice you to use requirejs.

But if you wanna use ES6 imports in NodeJS it will be possible in new vesions, now it is an experimental feature (you can read more here)

Try solution: update to the latest version on NodeJS

Alexey Nazarov
  • 1,403
  • 2
  • 9
  • 9