Cannot use import statement outside a module in app.config.js

This documentation link makes it seem like you can import in app.config.js

But when I import Constants and try to build, I get an error:

import Constants from 'expo-constants';
const releaseChannel = Constants.manifest.releaseChannel;

if (releaseChannel === undefined) {
  // some stuff
}

export default ({ config }) => {
  return {
    ...config,
    extra: extraConfig,
  };
};


Cannot use import statement outside a module
    ├─ readConfigFile /usr/local/lib/node_modules/expo-cli/node_modules/@expo/config/src/getConfig.ts:22:21
    ├─ getDynamicConfig /usr/local/lib/node_modules/expo-cli/node_modules/@expo/config/src/getConfig.ts:30:18
    ├─ getConfig /usr/local/lib/node_modules/expo-cli/node_modules/@expo/config/src/Config.ts:163:62
    ├─ new BaseBuilder /usr/local/lib/node_modules/expo-cli/src/commands/build/BaseBuilder.ts:27:26
    ├─ new IOSBuilder /usr/local/lib/node_modules/expo-cli/src/commands/build/ios/IOSBuilder.ts:51:1
    ├─ program.command.alias.helpGroup.option.option.option.option.option.option.option.option.option.option.option.option.option.option.option.option.option.option.option.description.asyncActionProjectDir.checkConfig /usr/local/lib/node_modules/expo-cli/src/commands/build/index.ts:127:28
    └─ expo build:ios /usr/local/lib/node_modules/expo-cli/src/exp.ts:346:7

Hey @mcgintech, this is the expected behavior. The documentation refers to the expo/config package that is designed to be used within app.config.js/ts files.

Cheers,
Adam

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.