错误出现的代码在此: https://github.com/i18next/next-i18next/blob/205e9a4fe5d5d1baca9f5a82561096b6372e1432/src/config/createConfig.ts#L211
2023-12-25 07:47 +00:00: Error: ENOENT: no such file or directory, scandir '/app/packages/eshop/public/locales/cn'
at Object.readdirSync (node:fs:1405:3)
at getLocaleNamespaces (/app/node_modules/next-i18next/dist/commonjs/config/createConfig.js:214:16)
at /app/node_modules/next-i18next/dist/commonjs/config/createConfig.js:231:20
at Array.map ()
at getNamespaces (/app/node_modules/next-i18next/dist/commonjs/config/createConfig.js:230:44)
at createConfig (/app/node_modules/next-i18next/dist/commonjs/config/createConfig.js:271:29)
at _callee$ (/app/node_modules/next-i18next/dist/commonjs/serverSideTranslations.js:201:53)
at tryCatch (/app/node_modules/@babel/runtime/helpers/regeneratorRuntime.js:44:17)
at Generator. (/app/node_modules/@babel/runtime/helpers/regeneratorRuntime.js:125:22)
at Generator.next (/app/node_modules/@babel/runtime/helpers/regeneratorRuntime.js:69:21) {
errno: -2,
syscall: 'scandir',
path: '/app/packages/eshop/public/locales/cn'
}
报错指向的是用的一个 next.js 的多语言库 next-i18next ,它在每次页面刷新的时候都会调用 fs.readdirSync 读取本地多语言 json 文件。
我也试过在容器里面大量调用(定时器模拟) fs.readdirSync 也没出现报错。
实在不知道是什么原因引起的...有了解的小伙伴吗?