【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

 

posted @   路边两盏灯  阅读(116)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· DeepSeek 开源周回顾「GitHub 热点速览」
· 物流快递公司核心技术能力-地址解析分单基础技术分享
· .NET 10首个预览版发布:重大改进与新特性概览!
· AI与.NET技术实操系列(二):开始使用ML.NET
· 单线程的Redis速度为什么快?
历史上的今天:
2021-08-29 【Azure 应用服务】使用PowerShell脚本上传文件至App Service目录  
点击右上角即可分享
微信分享提示