next-translate: ENOENT: no such file or directory, scandir '....\monorepo\pages'
Hi my nextjs root is inside a monorepo as ./apps/web/ but I get this error on start:
ENOENT: no such file or directory, scandir 'monorepo\pages'
Is it possible to scan until you hit the first i18n.json or something along those lines, then you know the root where ./pages directory is to be expected
Thanks! Great project
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Comments: 50 (17 by maintainers)
@mvierssen You can copy pages from .next folder as a temporary workaround, to not to copy source
I am using 1.0.1 version, it works fine with copied pages 1.0.7 is failing
Hi @gsambrotta, @krystianjj
As of
1.0.3, usage with NX brings this error:You will not be able to use it, unfortunately 😦
Once PR #527 got merged, next-translate will become NX-compatible.
To setup next-translate with NX, you have to:
(a) Either pass env variable
NEXT_TRANSLATE_PATHevery time you run nx commands:(b) or create
.local.envfile in the workspace root folder and define the var there:With (b) all nx commands will automatically read env from
.local.env. Runningnx serve myAppNamewill just work.Hi @sergeyshaykhullin, You have different problem… Nextjs must have
pagesdirectory because nextjs have build in router. Check if you copypagesto correct main directory of project.@aralroca yeah, of course. Thanks.
From
1.0.5-canary.1all goes smooth, no issues so far.Hi @shelooks16, @aralroca I just tested next-translate@1.04-canary.2 with NX and I confirm, now everything working great 😃 Thank you 👍
Did anyone manage to deploy to production using
NX-monorepoor anymonorepo? My guess is that.env.localis somehow not taken into account or not pointing to the same path when building for prod withnpm run start. Everything works just fine in dev (when usingnpx nx run myapp:serve). But on prod, I usenpm run start(>nx start) it fails.@aralroca @shelooks16 Thank you, I have fixed the above error. Thanks a lot
Hi @karolbilicki
this is fixed in 1.0.4 and 1.0.5. Below these versions you won’t be able to pair NX and next-translate 😦
are you using docker? I have been using the workaround with docker up until now and haven’t experienced any problems.
Hi, we’re also getting the same error. I believe there’s a bug in the templateWithHoc method because the code parsed into the method is valid but the output is not.
Input:
Output:
Hope it helps. 🙏
Here’s how to replicate:
choose Next.js & CSS
next.config.js:
/i18n.json:
result: