-
-
Notifications
You must be signed in to change notification settings - Fork 206
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ENOENT: no such file or directory, scandir '....\monorepo\pages' #395
Comments
@binary64 Would it be possible for you to do a reproducible example? 🙏 This would be a great help to us. 😊 The examples we have are already under monorepo and we haven't encountered this problem |
Here's how to replicate:
choose Next.js & CSS
next.config.js:
/i18n.json:
result:
|
Similar issue, I am working in a Next app deployed with a custom server. It is configured as a monorepo using In order to run the Next App from the custom server I had to configure the const Env = require('@app/env');
const port = parseInt(process.env.PORT, 10) || 8000;
const dev = Env.NODE_ENV !== 'production';
const app = Next({
dev,
dir: Path.resolve(process.env.NEXT_APP_PATH || '.') # dir where app (frontend) is located
}); However there is not such a thing to configure with next-translate. so, my const nextTranslate = require('next-translate');
module.exports = nextTranslate({}, { appPath: process.env.NEXT_APP_PATH }); It is not an elegant solution, but maybe it helps. |
This comment has been minimized.
This comment has been minimized.
@binary64 Now this can be defined using Prerelease: 1.0.1-canary.3 However, I have now come across another issue along withNx webpack loader... Babel should have to be executed after the next-translate webpack loader, but it's executed it before for some reason I don't know... Maybe it's me who doesn't have any experience with NX and maybe I left something behind 😕 |
@binary64 can you confirm that 1.0.1-canary.3 prerelease is working for you? Thank you 🙏 |
Hi! Thanks for the update, Unfortunately I get a similar error:
It should be looking in C:\p\proj\monorepo\apps\web\src\pages Note: I only have a C:\p\proj\monorepo\package.json - there is no C:\p\proj\monorepo\apps\web\package.json - maybe this is why |
Ops! @binary64 And are you setting |
With
|
Ah ok @binary64, it looks the same issue that I reported on this comment #395 (comment). I'm not sure why this happens... Babel should have to be executed after the next-translate webpack loader, but it's executed it before for some reason I don't know... I'm going to investigate. Thank you. |
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: // Legacy CSS implementations will `eval` browser code in a Node.js context
// to extract CSS. For backwards compatibility, we need to check we're in a
// browser context before continuing.
if (typeof self !== 'undefined' &&
// AMP / No-JS mode does not inject these helpers:
'$RefreshHelpers$' in self) { Output: // Legacy CSS implementations will `eval` browser code in a Node.js context
// to extract CSS. For backwards compatibility, we need to check we're in a
// browser context before continuing.
if (typeof self !== 'undefined' &&
// AMP / No-JS mode does not inject these helpers:
'$RefreshHelpers
// @ts-ignore
export default __appWithI18n(__Page_Next_Translate__, { Hope it helps. 🙏 |
we move it to 1.0.3 to avoid blocking 1.0.2 |
Hi guys, I have the same error but I'm not sure is caused by the same issues. I don't include My main question is: |
@aralroca I tried out my solution with 1.0.3-canary and it didn't change much. My file tree:
My steps: Here i get the error: I still wonder if I should have |
Hi, |
As of 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
(b) or create
With (b) all nx commands will automatically read env from |
I pre-released the fix that @shelooks16 did under 1.0.4-canary.2. If you confirm that it works well, then I'm going to release it! |
Hmm, in production i have a If i disable next-translate plugin next will start without errors and serve/render pages as normal |
@sergeyshaykhullin if you use this Dockerfile configuration -> https://nextjs.org/docs/deployment you must add lines to copy i18n.js configuration to buid image if you have next-translate config in separare file. |
@krystianjj If you don't copy i18n.json you will get another error This is my Dockerfile FROM node:16-alpine as build
WORKDIR /app
COPY . .
RUN npm ci
RUN npm run build
RUN npm prune --production
FROM node:16-alpine
WORKDIR /app
COPY --from=build /app/public public
COPY --from=build /app/.next .next
COPY --from=build /app/next.config.js next.config.js
COPY --from=build /app/node_modules node_modules
COPY --from=build /app/package.json package.json
COPY --from=build /app/i18n.json i18n.json
# TODO: HACK https://github.com/vinissimus/next-translate/issues/395
COPY --from=build /app/src/pages src/pages
ENTRYPOINT ["npm", "start"] |
@sergeyshaykhullin your |
@krystianjj Yes, this configuration is working But you should not to copy your source pages So that's why i have TODO: HACK comment |
@sergeyshaykhullin in my project when I comment line with |
@krystianjj Yes, if you disable next-translate you can omit copying source pages and next will use .next/server/pages If you uncomment your |
I run into the same issue. The docker file as described here: https://nextjs.org/docs/deployment ...cannot work because next-translate seems to want the source pages to be included inside the docker image unlike the example from the link above. |
Ok I reopen it! |
@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 |
This works for me COPY --from=builder /app/.next/server/pages ./pages basically you need copy pages from .next/server/pages to workdir. Idk why is needed. |
Thanks @sergeyshaykhullin and @xerenahmed . That seems like a good workaround for now. |
1.05 - the workaround with copied pages doesn't work (prod), dev environment works fine so dev and prod don't work together on the same version 😞 any suggestions? |
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. |
I am going to use 1.01 in order to use the workaround with coping pages directory for prod. For development I will upgrade the version to 1.07 but only locally. |
Any more workarounds?.. |
help me error ./pages/blog/[detail].tsx
|
It should be fixed in 1.1.0-canary.4 version. I close the issue but it would be nice to know your feedback that now it works without problems. If not, I will reopen the issue. |
@aralroca help me. It still doesn't work on nx workspaces. The problem is still in 2 pages on the same folder and both use getServerSideProps |
@aralroca please help me |
@quyphan97 try to use function expression for the component and function declaration for getServerSideProps: const MyPage = () => { ... }
export async function getServerSideProps() { ... } |
@shelooks16 Thanks. I will report back to you once the results are available |
@quyphan97 @shelooks16 I've made a fix in the 1.1.0-canary.5, I hope that with this version it will work. |
@aralroca @shelooks16 Thank you, I have fixed the above error. Thanks a lot |
Did anyone manage to deploy to production using |
Same issue here @danyhiol. Please let me know if you have resolved this |
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
The text was updated successfully, but these errors were encountered: