title: Which metro bundler settings are needed to resolve React Native's internal modules?
body: <p>I have initialized a new React Native project (0.57.4) with <code>react-native init</code> and am trying to run the <a href="https://facebook.github.io/metro/" rel="nofollow noreferrer">Metro</a> bundler on it programmatically; however, it is unable to resolve React Native's internal modules (e.g. <code>AccessibilityInfo</code>) which is the first module <code>require</code>d in the React Native source:</p>
  
  <pre><code>Error: Unable to resolve module `AccessibilityInfo` from `/myproject/node_modules/react-native/Libraries/react-native/react-native-implementation.js`: Module `AccessibilityInfo` does not exist in the Haste module map
  </code></pre>
  
  <p>Following instructions to clear caches does not help.</p>
  
  <p>Here is the code I am using to run the <code>Metro</code> bundler programmatically:</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>const path = require('path')
  const metro = require('metro')
  
  const entry = './index.js'
  const out = './build/index.bundle'
  const platform = 'ios'
  const root = process.cwd()
  
  build()
  
  async function build() {
  
    const config = {
      resolver: {
        providesModuleNodeModules: ['react-native'],
      },
      transformer: {
        babelTransformerPath: require.resolve('metro/src/reactNativeTransformer'),
      },
      serializer: {},
      server: {},
      projectRoot: root,
      watchFolders: [root, path.join(__dirname, 'node_modules', 'metro')],
    }
  
    const opts = { dev: false, entry, optimize: true, out, platform, sourceMap: true }
  
    return await metro.runBuild(config, opts)
  }</code></pre>
  </div>
  </div>
  </p>
  
  <p>I suspect I may be missing a setting that will allow <code>Metro</code> to resolve React Natives modules marked with the <code>@providesModule</code> header comment.</p>