Skip to content
TheChatArchiveThe Chat Archive
Geminigemini-2.5-pro· GoogleHugging Face LMArena Human Preference 140K

Cannot automatically write to dynamic config at: app.config.js Add the following to your…

From a Chatbot Arena battleThe same person sent this prompt to two anonymous models at once. Compare it with gpt-4.1-2025-04-14’s answer.
  1. User

    Cannot automatically write to dynamic config at: app.config.js Add the following to your Expo config

    { "plugins": [ "expo-localization" ] }

  2. Gemini Assistant

    Excellent question! You've run into a very common and important part of using Expo with libraries that require native capabilities. Let me explain exactly what this message means and how to fix it.

    Why You're Seeing This Error

    This error occurs because you are using a dynamic configuration file (app.config.js) instead of a static one (app.json).

    • app.json (Static): A simple JSON file containing configuration data. The Expo CLI (expo install) can easily and safely add new lines to this file automatically.
    • app.config.js (Dynamic): A JavaScript file that exports a configuration object. This allows you to use logic, environment variables, and functions to build your config. Because it's code, the Expo CLI will not attempt to modify it automatically to avoid breaking your logic.

    So, when you ran npx expo install expo-localization, the tool recognized that expo-localization requires a "plugin" entry in your config file. It tried to add it, saw you were using app.config.js, and instead of modifying it, it printed the exact instruction you need to follow manually.

    The Solution: Manually Add the Plugin

    You just need to do exactly what the error message says.

    Step 1: Open Your app.config.js File

    Find and open the app.config.js file in the root directory of your project. It will look something like this (your specific content may vary):

    // app.config.js
    
    export default {
      expo: {
        name: "my-awesome-app",
        slug: "my-awesome-app",
        version: "1.0.0",
        orientation: "portrait",
        icon: "./assets/icon.png",
        userInterfaceStyle: "light",
        splash: {
          image: "./assets/splash.png",
          resizeMode: "contain",
          backgroundColor: "#ffffff"
        },
        assetBundlePatterns: [
          "**/*"
        ],
        ios: {
          supportsTablet: true
        },
        android: {
          adaptiveIcon: {
            foregroundImage: "./assets/adaptive-icon.png",
            backgroundColor: "#ffffff"
          }
        },
        web: {
          favicon: "./assets/favicon.png"
        }
        // You might not have a "plugins" array here yet
      }
    };
    

    Step 2: Add the plugins Array

    Inside the expo object, find or add a plugins array. Then, add the string "expo-localization" to that array.

    Here is how your app.config.js should look after the change:

    // app.config.js
    
    export default {
      expo: {
        name: "my-awesome-app",
        slug: "my-awesome-app",
        version: "1.0.0",
        orientation: "portrait",
        icon: "./assets/icon.png",
        userInterfaceStyle: "light",
        splash: {
          image: "./assets/splash.png",
          resizeMode: "contain",
          backgroundColor: "#ffffff"
        },
        assetBundlePatterns: [
          "**/*"
        ],
        ios: {
          supportsTablet: true
        },
        android: {
          adaptiveIcon: {
            foregroundImage: "./assets/adaptive-icon.png",
            backgroundColor: "#ffffff"
          }
        },
        web: {
          favicon: "./assets/favicon.png"
        },
        // --- ADD THIS PART ---
        plugins: [
          "expo-localization"
        ]
        // ---------------------
      }
    };
    

    Important: If you already have a plugins array with other items, just add "expo-localization" to the list:

    plugins: [
      "some-other-plugin",
      "expo-localization" // Add it here
    ]
    

    Step 3: Restart Your Development Server

    After saving the changes to app.config.js, you must restart your development server for the new configuration to take effect.

    1. Stop the Metro server (press Ctrl + C in the terminal where it's running).
    2. Restart it. It's good practice to clear the cache after a config change.
    npx expo start -c
    

    The -c flag clears the cache, ensuring your configuration changes are properly loaded.

    What Does This Plugin Do?

    The expo-localization library needs to access native device APIs on iOS and Android to get the user's locale (language, region, etc.). The plugin system in Expo is the bridge that connects your JavaScript code to this required native code.

    By adding "expo-localization" to the plugins array, you are telling Expo's build system (EAS Build or the npx expo prebuild command) to include and configure the necessary native modules for localization when your app is built.

    You can now continue with the rest of the steps outlined in the previous guide, starting from Step 2: Create Translation Files. Your setup is now correct.

Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.