【Azure App Service for Linux】NodeJS镜像应用启动失败,遇见 RangeError: Incorrect locale information provided
问题描述
在App Service For Linux 中,部署NodeJS应用,应用启动失败。
报错信息为:
2023-08-29T11:21:36.329731566Z RangeError: Incorrect locale information provided
2023-08-29T11:21:36.329776866Z at Intl.getCanonicalLocales (<anonymous>)
2023-08-29T11:21:36.329783066Z at CanonicalizeLocaleList (/app/web/.next/server/chunks/8112.js:396:17)
2023-08-29T11:21:36.329797266Z at match (/app/web/.next/server/chunks/8112.js:656:108)
2023-08-29T11:21:36.329801166Z at getLocaleOnServer (/app/web/.next/server/chunks/7614.js:162:63)
2023-08-29T11:21:36.329804566Z at LocaleLayout (/app/web/.next/server/chunks/7614.js:89:55)
2023-08-29T11:21:36.329808467Z at X (/app/web/.next/server/chunks/8112.js:2419:13)
2023-08-29T11:21:36.329811967Z at Na (/app/web/.next/server/chunks/8112.js:2587:21)
2023-08-29T11:21:36.329815367Z at Array.toJSON (/app/web/.next/server/chunks/8112.js:2347:20)
2023-08-29T11:21:36.329818767Z at stringify (<anonymous>)
2023-08-29T11:21:36.329822167Z at da (/app/web/.next/server/chunks/8112.js:1861:9)
2023-08-29T11:21:36.339132982Z [Error: An error occurred in the Server Components render. The specific message is omitted in production builds to avoid leaking sensitive details. A digest property is included on this error instance which may provide additional details about the nature of the error.] {
2023-08-29T11:21:36.339162983Z digest: '833304465'
2023-08-29T11:21:36.339168383Z }
问题解答
当前App Service 应用使用 node:18 的镜像启动,这个镜像是基于Debian的,且没有安装locales相关packages。
在镜像(Dockerfile)中加入以下命令可以成功启动:
RUN apt-get update RUN apt-get -y install locales RUN sed -i '/en_US.UTF-8/s/^# //g' /etc/locale.gen && \ locale-gen ENV LANG en_US.UTF-8 ENV LANGUAGE en_US:en ENV LC_ALL en_US.UTF-8
当在复杂的环境中面临问题,格物之道需:浊而静之徐清,安以动之徐生。 云中,恰是如此!
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· DeepSeek 开源周回顾「GitHub 热点速览」
· 物流快递公司核心技术能力-地址解析分单基础技术分享
· .NET 10首个预览版发布:重大改进与新特性概览!
· AI与.NET技术实操系列(二):开始使用ML.NET
· 单线程的Redis速度为什么快?
2021-08-29 【Azure 应用服务】使用PowerShell脚本上传文件至App Service目录