If anyone else encounters the same issue, to fix it, add the following line to the package.json
: ' type": "module", under version
or name
.
Also, next.config.js
needs to be either .js
or mjs
; ts
or mts
won't work.
After all of this, you still need to use the code from the question to generate the static pages using the function generateStaticParams
. It needs to be named generateStaticParams
.
Also, instead of using the nextjs dynamic routes with [slug] I think it's better to just use query
like in the answer from @Yahya Aghdam