Cannot automatically write to dynamic config at: app.config.js Add the following to your…
- User
Cannot automatically write to dynamic config at: app.config.js Add the following to your Expo config
{ "plugins": [ "expo-localization" ] }
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 thatexpo-localizationrequires a "plugin" entry in your config file. It tried to add it, saw you were usingapp.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.jsFileFind and open the
app.config.jsfile 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
pluginsArrayInside the
expoobject, find or add apluginsarray. Then, add the string"expo-localization"to that array.Here is how your
app.config.jsshould 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
pluginsarray 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.- Stop the Metro server (press
Ctrl + Cin the terminal where it's running). - Restart it. It's good practice to clear the cache after a config change.
npx expo start -cThe
-cflag clears the cache, ensuring your configuration changes are properly loaded.What Does This Plugin Do?
The
expo-localizationlibrary 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 thepluginsarray, you are telling Expo's build system (EAS Build or thenpx expo prebuildcommand) 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.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.