ReactJS [issue on production] - TypeError: (void 0) is not a function

Viewed 2276

'

I'm facing the above error on production build, not even getting the issue reference... your help will really be appreciated, Thanks in advance.

Note - on local, it works fine - development mode, but the same code won't work on a production.

React js version is - 16.12.0, and webpack version - 4.41.6

2 Answers

I had this issue when working with team and we don't have git ignore for ios project so the core files doesn't belong to the same compiler , i managed to resolve this issue by first deleting ios folder (if you use pod copy podfile)

then react-native upgrade --legacy true copy your pod file again to the new ios folder cd ios pod install cd - open your project in xcode and build select schema to release then build again

Don't forget to have git ignore as follow

Facing this issue when trying to import something that is not exported from a module. I'm sure this is the case only for PRODUCTION build, not for development.

Probably, this error is only applicable for Webpack 4 and has been fixed in Webpack 5.

In my case:

index.js of a module:

export {
  foo,
} from './utils';

Your file:

import * as Utils from 'utils';

Utils.bar(); // bar is not exported!

Production bundle contains: (void 0)() // crashes!

Development bundle contains user friendly comment:

/* Cannot get final name for export "bar" in 
   "./node_modules/utils/index.js" (known exports: foo) */

undefined();

and fails silently ‍♂️

Related