Receive notifications about upcoming Intlayer releases

    Error on build on CI/CD

    If you get an error like this on Next.js:

    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

    Here some solutions:

    1. Missing dictionaries

    Ensure that the dictionaries are built at the stage of the build.

    It's frquent that the build works locally but not on CI/CD. The reason is that locally, the .intlayer directory is present, but on CI/CD, it's not as it's excluded from the build.

    You can fix it by adding a prebuild script in the package.json of your project.

    {  // ...  "scripts": {    "prebuild": "npx intlayer dictionaries build", // Will run before the build    "build": "next build",  },}
    Not that if you use the withIntlayer function, or the equivalent bundler plugin for your framework, the prebuild script will be run before the build.

    2. Missing environment variables at build / run time

    In a container, or auto-deployed platform, it's recommended to exclude the .env file from the build.

    .gitignore or .dockerignore
    # Environment variables.env**/.env.env.***/.env.*

    If your environment variables are not available at build time, an error will be thrown.

    import { Metadata } from "next";export const generateMetadata = async ({ params }): Promise<Metadata> => ({  metadataBase: new URL(process.env.NEXT_PUBLIC_URL),});

    It's probably not related to Intlayer. So check your environment variables at build time on your CI/CD platform.