next-translate
next-translate copied to clipboard
Deploy on production with next-translate
Hi there, I have a simple Nextjs app which use next-translate and I'm struggling to deploy it. I don't have a clear idea how deployment process works yet so it might be not related to next-translate but basically I have this file structure:
.next/
node_modules/
package.json
package-lock.json
public/
And for what I understood reading A LOT, it should just work when I run
npm run build
npm start
If i do so, I get an error because of i18n.js
is missing.
I then add my i18n.js
file that look like this:
module.exports = {
locales: ['en', 'it'],
defaultLocale: 'en',
pages: {
'*': ['common'],
'/': ['home'],
'/why-water': ['whyWater'],
'/about': ['about'],
'/terms': ['terms'],
'/privacy': ['privacy'],
'/search': ['search']
}
}
If i now build and then run npm start
, it fails looking for pages/
directory.
Why should I add the pages directory? Is not compiled code, it shouldn't be needed in production.
Can someone please clarify this to me? Would be really helpful!
@gsambrotta I think is the same issue reported here: https://github.com/vinissimus/next-translate/issues/395 On the issue there is a workaround proposed to temporal fix this. Hope it helps 😊
Hi @aralroca the problem on #395 is not connected to mine, i don't have a monorepo. Nevertheless I tired to install the canary version but didn't fix my problem.
Can you please tell me if /pages are needed to deploy to production?
As much as I understood, they shouldn't be part of a production ready nextjs application.
Hi @aralroca I tried again with the new 1.0.5-canary release but I still get the same error. If you want to see an example, I push the code here: https://github.com/ElliotForWater/efw-webapp/tree/next-translate-update/efw-prod
If I build the project, is still looking for /pages
directory. Which I think it shouldn't.
I know you have a lot of issues open and probably little time but would be really great for me to have an input from you, to at least understand if is expected that pages/
folder is in the code deployed to a production server.
thanks!
@gsambrotta
COPY --from=builder /app/.next/server/pages ./pages
Don't need to provide your source code. Provide the pages from the build. It worked for me.
@gsambrotta did you manage to solve this? I am having this issue on an NX-MONOREPO
.
The error says: Error: Cannot find module '/opt/render/project/src/dist/apps/myapp/i18n'
When I copy i18n.json
to my build (I don't think this should be done). I get your error.
I have the same issue still. Has anyone here found a solution?