Skip to content
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

Builds error when using next's i18n due to lack of serverless/pages/index.html file #75

Closed
neefrehman opened this issue Dec 28, 2020 · 22 comments · Fixed by netlify/next-on-netlify#163

Comments

@neefrehman
Copy link

I'm trying to move a Next.js site (which uses next's i18n routing) over to Netlify, but sadly can't due to this error:

Error: ENOENT: no such file or directory, stat '.next/serverless/pages/index.html'

It's true that this file doesn't exist. Instead, the default homepage can be found at '.next/serverless/pages/en/index.html' (replacing "en" with whatever default locale is set in next.config.js).

It would be great to detect if i18n is in use, and then get the homepage's file location by reading the default locale.

@yerffejytnac
Copy link

Same issue here

@lindsaylevine
Copy link

hey yall! @neefrehman @cantyjeffrey our i18n PR in next-on-netlify was merged and released this past sunday netlify/next-on-netlify#75. i will go ahead and upgrade the plugin's next-on-netlify version now. admittedly, we need a better workflow for keeping the plugin up to date with next-on-netlify updates. thank you for your patience!!!

@lindsaylevine
Copy link

update: i upgraded the next-on-netlify version and re-released the plugin. i18n should work now in plugin version 1.0.4!

@neefrehman
Copy link
Author

neefrehman commented Jan 6, 2021

@lindsaylevine thanks for the update!

I've just tried deploying my site with the new plugin and am getting a similar error. It looks like the plugin is searching for the entry point at pages/${locale}/.html as opposed to pages/${locale}/index.html

10:52:20 AM: ────────────────────────────────────────────────────────────────
10:52:20 AM:   Plugin "@netlify/plugin-nextjs" internal error                
10:52:20 AM: ────────────────────────────────────────────────────────────────
10:52:20 AM: ​
10:52:20 AM:   Error message
10:52:20 AM:   Error: ENOENT: no such file or directory, stat '.next/serverless/pages/en/.html'
10:52:20 AM: ​
10:52:20 AM:   Plugin details
10:52:20 AM:   Package:        @netlify/plugin-nextjs
10:52:20 AM:   Version:        1.0.4
10:52:20 AM:   Repository:     git+https://github.com/netlify/netlify-plugin-nextjs.git
10:52:20 AM:   npm link:       https://www.npmjs.com/package/@netlify/plugin-nextjs
10:52:20 AM:   Report issues:  https://github.com/netlify/netlify-plugin-nextjs/issues

@lindsaylevine lindsaylevine reopened this Jan 6, 2021
@lindsaylevine
Copy link

oh no what page type is your index!? @neefrehman thats so odd after my thorough testing 🤔

@lindsaylevine
Copy link

actually thats really not odd i had opened this issue for myself 😭 netlify/next-on-netlify#122

@neefrehman
Copy link
Author

hah! well if it's still useful my index page is just a standard index.tsx in my pages directory

@lindsaylevine
Copy link

im able to repro, ill keep ya updated. apologies!

@lindsaylevine
Copy link

i believe this is the fix netlify/next-on-netlify#131 now just need to go through the re-release of everything 😅

btw when i asked for page type (sorry that was unclear) i meant are you using getStaticProps (likely since the build is looking for html) and are you using fallback and/or revalidate

@neefrehman
Copy link
Author

Ah understood! Yes it's a getStaticProps page without any revalidation or fallback :)

@lindsaylevine
Copy link

@neefrehman ok 1.0.5 is released now. hopefully you have a clean build and functioning i18n with this version! 🙏

@neefrehman
Copy link
Author

I've actually just tried a build! It's moving past the old error, but now I'm getting the below error regarding function bundling.

I guess the important piece is : Cannot find module 'critters'

I'm not sure if this is related?

11:35:56 AM: ────────────────────────────────────────────────────────────────
11:35:56 AM:   Dependencies installation error                               
11:35:56 AM: ────────────────────────────────────────────────────────────────
11:35:56 AM: ​
11:35:56 AM:   Error message
11:35:56 AM:   A Netlify Function failed to require one of its dependencies.
11:35:56 AM:   If the dependency is a Node module, please make sure it is present in the site's top-level "package.json".
  If it is a local file instead, please make sure the file exists and its filename is correctly spelled.
11:35:56 AM: ​
11:35:56 AM:   In file "/opt/build/repo/netlify-automatic-functions/next_index/next_index.js"
11:35:56 AM:   Cannot find module 'critters'
11:35:56 AM:   Require stack:
11:35:56 AM:   - /opt/buildhome/.netlify-build-nvm/versions/node/v12.16.3/lib/node_modules/@netlify/build/node_modules/@netlify/zip-it-and-ship-it/src/node_dependencies/resolve.js
11:35:56 AM:   - /opt/buildhome/.netlify-build-nvm/versions/node/v12.16.3/lib/node_modules/@netlify/build/node_modules/@netlify/zip-it-and-ship-it/src/node_dependencies/index.js
11:35:56 AM:   - /opt/buildhome/.netlify-build-nvm/versions/node/v12.16.3/lib/node_modules/@netlify/build/node_modules/@netlify/zip-it-and-ship-it/src/main.js
11:35:56 AM:   - /opt/buildhome/.netlify-build-nvm/versions/node/v12.16.3/lib/node_modules/@netlify/build/src/plugins_core/functions/index.js
11:35:56 AM:   - /opt/buildhome/.netlify-build-nvm/versions/node/v12.16.3/lib/node_modules/@netlify/build/src/commands/get.js
11:35:56 AM:   - /opt/buildhome/.netlify-build-nvm/versions/node/v12.16.3/lib/node_modules/@netlify/build/src/core/main.js
11:35:56 AM:   - /opt/buildhome/.netlify-build-nvm/versions/node/v12.16.3/lib/node_modules/@netlify/build/src/core/bin.js
11:35:56 AM: ​
11:35:56 AM:   Resolved config
11:35:56 AM:   build:
11:35:56 AM:     command: npm run build
11:35:56 AM:     commandOrigin: config
11:35:56 AM:     environment:
11:35:56 AM:       - NODE_VERSION
11:35:56 AM:     publish: /opt/build/repo/out
11:35:56 AM:   plugins:
11:35:56 AM:     - inputs: {}
11:35:56 AM:       origin: config
11:35:56 AM:       package: netlify-plugin-cache-nextjs
11:35:56 AM:     - inputs: {}
11:35:56 AM:       origin: config
11:35:56 AM:       package: '@netlify/plugin-nextjs'

@lindsaylevine
Copy link

oh dear. this is a known issue as well! see: https://twitter.com/erikras/status/1341783510055567361?s=20 and netlify/next-on-netlify#103

temporary fix is to install critters in your project. question though before doing that - can you try adding a next.config.js (if you dont already have one) and setting the target to experimental-serverless-trace (if it isn't already set to that)?

@lindsaylevine
Copy link

lindsaylevine commented Jan 6, 2021

also, best to reply on netlify/next-on-netlify#103 if you can! regarding critters. if i18n is all good for you here, i'll close this issue :)

@neefrehman
Copy link
Author

@lindsaylevine sorry for opening another issue again, but I've just updated the plugin to fix the resurfaced critters issue (netlify/next-on-netlify#157), and now and getting one similar to this again. It looks like the plugin is looking for a file like pages/{defaultLocale}/{defaultLocale}.html instead of pages/{defaultLocale}/index.html.

More info:

11:34:25 AM: ────────────────────────────────────────────────────────────────
11:34:25 AM:   Plugin "@netlify/plugin-nextjs" internal error                
11:34:25 AM: ────────────────────────────────────────────────────────────────
11:34:25 AM: ​
11:34:25 AM:   Error message
11:34:25 AM:   Error: ENOENT: no such file or directory, stat '.next/serverless/pages/en/en.html'
11:34:25 AM: ​
11:34:25 AM:   Plugin details
11:34:25 AM:   Package:        @netlify/plugin-nextjs
11:34:25 AM:   Version:        1.1.0
11:34:25 AM:   Repository:     git+https://github.com/netlify/netlify-plugin-nextjs.git
11:34:25 AM:   npm link:       https://www.npmjs.com/package/@netlify/plugin-nextjs
11:34:25 AM:   Report issues:  https://github.com/netlify/netlify-plugin-nextjs/issues

@lindsaylevine
Copy link

@neefrehman don't be sorry at all!!! yikes, that's not good though @ bug. let me try to repro.

@lindsaylevine
Copy link

repro'd, stay tuned

@lindsaylevine lindsaylevine reopened this Feb 1, 2021
@lindsaylevine
Copy link

this issue is haunting me netlify/next-on-netlify#122

@lindsaylevine
Copy link

i assume you're using next 10.0.6 because something definitely changed internally :rip:

@lindsaylevine
Copy link

aight, i know what's going on. are you blocked by this? if so, i think the workaround is to downgrade next until i can release a fix

@neefrehman
Copy link
Author

great! i'm not blocked, so happy to downgrade for now. it must be a big challenge to continue covering all cases

@lindsaylevine
Copy link

this was just released! let me know if you continue to have any issues!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants