Hi I just started playing around with nextjs to see if it fits my use case. I wanted to export the site with some dynamic routes.
My pages folder structure is like below
page
locales
[locale]
[slug].js
When I run next develop
I can access the page at http://localhost:3000/locales/de-DE/summer-dress-f
.
So now im trying to export the page with next.config.js
like
module.exports = {
exportPathMap: function() {
return {
"/locales/de-DE/summer-dress-f": {
page: "/locales",
query: { locale: "de-DE", slug: "summer-dress-f" }
}
};
}
};
next build
runs fine but when I run next export
I get the error
Error: Cannot find module for page: /locales
at pageNotFoundError (/Users/bmathew/Desktop/workspace/next-demo/node_modules/next-server/dist/server/require.js:13:17)
Any ideas what am I missing here?
Running npm install
seems to fix this.
Finally figured it out. The pathmap should look like
module.exports = {
exportPathMap: function() {
return {
"/locales/de-DE/summer-dress-f": {
page: "/locales/[locale]/[slug]",
query: { locale: "de-DE", slug: "summer-dress-f" }
}
};
}
};
Page component naming should be unique. So I had about.tsx with name: AboutPage and faqs.tsx with name: AboutPage as well, amending faqs.tsx to be unique fixed it :)
I just hit a similar error, and I had simply forgotten to run next build
before next export
!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With