Closed
Description
Describe the bug
When deployed to Vercel the serverSideTranslations
function crashes when called inside getServerSideProps
. When called in getStaticProps
it works as expected. Locally everything runs fine.
The deployed Vercel serverless function in which it runs gives me error:
2021-11-28T16:16:28.536Z 1d6d712f-02d3-4029-8277-7bf418949555 ERROR Error: ENOENT: no such file or directory, scandir '/var/task/public/locales/cs'
at Object.readdirSync (fs.js:1047:3)
at getLocaleNamespaces (/var/task/node_modules/next-i18next/dist/commonjs/config/createConfig.js:175:23)
at /var/task/node_modules/next-i18next/dist/commonjs/config/createConfig.js:181:20
at Array.map (<anonymous>)
at getNamespaces (/var/task/node_modules/next-i18next/dist/commonjs/config/createConfig.js:180:44)
at createConfig (/var/task/node_modules/next-i18next/dist/commonjs/config/createConfig.js:221:29)
at _callee$ (/var/task/node_modules/next-i18next/dist/commonjs/serverSideTranslations.js:199:53)
at tryCatch (/var/task/node_modules/regenerator-runtime/runtime.js:63:40)
at Generator.invoke [as _invoke] (/var/task/node_modules/regenerator-runtime/runtime.js:294:22)
at Generator.next (/var/task/node_modules/regenerator-runtime/runtime.js:119:21) {
errno: -2,
syscall: 'scandir',
path: '/var/task/public/locales/cs',
page: '/ssr'
}
RequestId: 1d6d712f-02d3-4029-8277-7bf418949555 Error: Runtime exited with error: exit status 1
Runtime.ExitError
Occurs in next-i18next version
^9.2.0
Steps to reproduce
Reproduction repository:
https://github.com/jakubHynek/vercel-next-18next
Running example
https://translations-wo-monorepo-kubhynek.vercel.app/
I initialized app using yarn create next-app --typescript
and added simple translation using next-i18next
.
- There is index page (
/
) -- withserverSideTranslations
called insidegetStaticProps
, there is a button that takes you to/ssr
page - There is ssr page (
/ssr
) -- withserverSideTranslations
called insidegetServerSideProps
-- this page crashes
Steps
yarn install
npx vercel
- follow the steps of Vercel initialization
- open the deployment and click the pink button to go to page with getServerSideProps -> crash
Metadata
Metadata
Assignees
Labels
No labels