Search code examples
react-nativebabel-loader

Cannot find module 'warnOnce'


When i upgrade my react-native version to 0.59.5 and i run webpack to create a bundle for my web app in the same folder app i get this error

  Module build failed (from ./node_modules/babel-loader/lib/index.js):
  Error: Cannot find module 'warnOnce'
  at Function.Module._resolveFilename 
  (internal/modules/cjs/loader.js:603:15)

I can't understand where is used this WarnOnce and how can i fix it ? Does someone face the same issue ? I did a cache clean and it still not working


Solution

  • Add resolver in module.exports in your metro.config.js and make sure it looks something like below.

    const blacklist = require('metro-config/src/defaults/blacklist');
    
    module.exports = {
      resolver: {
        blacklistRE: blacklist([
          /node_modules\/.*\/node_modules\/react-native\/.*/,
        ])
      },
      transformer: {
        getTransformOptions: async () => ({
          transform: {
            experimentalImportSupport: false,
            inlineRequires: false,
          },
        }),
      },
    };