问题描述

在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

 



当在复杂的环境中面临问题,格物之道需:浊而静之徐清,安以动之徐生。 云中,恰是如此!

阿里云国内75折 回扣 微信号:monov8
阿里云国际,腾讯云国际,低至75折。AWS 93折 免费开户实名账号 代冲值 优惠多多 微信号:monov8 飞机:@monov6
标签: NodeJSlinux