Using import statement in app.config.js causes an error

🐛 Bug Report tells me I can use import statements in app.config.js but it doesn’t work.

Summary of Issue (just a few sentences)

I wanted to use import Constants from 'expo-constants'; in app.config.js but it gives me an error

Environment – output of expo diagnostics & the platform(s) you’re targeting

Expo CLI 3.21.5 environment info:
      OS: macOS Mojave 10.14.6
      Shell: 3.2.57 - /bin/bash
      Node: 12.12.0 - /usr/local/bin/node
      Yarn: 1.19.1 - /usr/local/bin/yarn
      npm: 6.11.3 - /usr/local/bin/npm
      Android Studio: 3.6 AI-192.7142.36.36.6241897
      Xcode: 11.3.1/11C504 - /usr/bin/xcodebuild
      expo: ~37.0.3 => 37.0.8
      react: ~16.9.0 => 16.9.0
      react-dom: ~16.9.0 => 16.9.0
      react-native: => 0.61.4
      react-native-web: ~0.11.7 => 0.11.7
      expo-cli: 3.21.5

Reproducible Demo

  • This should include as little code as possible, please don’t simply link your entire project
  • Sharing a link to a Snack is a GREAT way to provide a reproducible demo 🙂
  • If a reproducible demo, or a complete list of steps from blank project to bug, are not provided, it is very likely your issue will be closed
  • If you need more guidance, please see

As an added benefit- creating a repro may help you identify the source of the bug, which means we are one step closer to fixing it! Thanks for helping us help you!

Steps to Reproduce

create app.config.js and add import Constants from 'expo-constants';

Expected Behavior vs Actual Behavior

the app runs without problems.


import { AppOwnership, UserInterfaceIdiom, } from './Constants.types';

SyntaxError: Cannot use import statement outside a module
    at Module._compile (internal/modules/cjs/loader.js:892:18)
    at Module._compile (/usr/local/lib/node_modules/expo-cli/node_modules/pirates/lib/index.js:99:24)
    at Module._extensions..js (internal/modules/cjs/loader.js:973:10)
    at Object.newLoader [as .js] (/usr/local/lib/node_modules/expo-cli/node_modules/pirates/lib/index.js:104:7)
    at Module.load (internal/modules/cjs/loader.js:812:32)
    at Function.Module._load (internal/modules/cjs/loader.js:724:14)
    at Module.require (internal/modules/cjs/loader.js:849:19)
    at require (internal/modules/cjs/helpers.js:74:18)
    at Constants (/Users/swatanabe025/Desktop/private/OtsukaiChain/packages/clients/supporter/app.config.js:1:1)
    at Object.<anonymous> (/Users/swatanabe025/Desktop/private/OtsukaiChain/packages/clients/supporter/app.config.js:4:28)

1 possible answer(s) on “Using import statement in app.config.js causes an error