Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

babelHelpers.typeof is not a function #5

Closed
itinance opened this issue Aug 18, 2016 · 21 comments
Closed

babelHelpers.typeof is not a function #5

itinance opened this issue Aug 18, 2016 · 21 comments

Comments

@itinance
Copy link
Contributor

Suddenly any .babelrc with preset "es2015" should be avoided in ReactNative-Applications because it gives the exception mentioned in title.

More hints about that can be found in the solution and their comments to this question on SO:
http://stackoverflow.com/questions/39016025/reactnative-babelhelpers-typeof-is-not-a-function

Quote:

The issue happens because either your project (via a custom .babelrc) or one of your dependencies is relying on a es2015 preset that doesn't work with React Native. The reason for that is because it includes transform-typeof-symbol which calls babelHelpers.typeof that is not bundled with React Native.

If you have a custom babelrc - the solution is simple, just remove this preset. Afterwards, restart packager w/o cache and you should be set.

@itinance
Copy link
Contributor Author

PR added: #6

@sibelius
Copy link
Owner

fixed on master

@sibelius sibelius reopened this Aug 18, 2016
@sibelius
Copy link
Owner

there is a problem with ur solution

npm run build stopped working

@itinance
Copy link
Contributor Author

I will check this out

@sibelius
Copy link
Owner

maybe we could add .babelrc to .npmignore

@itinance
Copy link
Contributor Author

sounds like a good idea. I'll check this out right now

@itinance
Copy link
Contributor Author

itinance commented Aug 18, 2016

I've tried it out in this branch, but then nothing is installed. So you should revert my PR. Sorry

A solution right now would be to install the master branch from version before my PR and then to locally remove the .babelrc-file (and don't forget to repeat this again after reinstalling all node-modules on some day when it becomes necessary)

@sibelius
Copy link
Owner

if u r using react-native-in-app-utils package, do u mind submit a PR to add this function to that library without .babelrc (chirag04/react-native-in-app-utils#25 (comment))

and we can keep this with .babelrc for now

@AdrienLemaire
Copy link

Having this issue, and removing the .babelrc from the node_packages/iap-receipt-validator didn't solve the problem...
My repository's babelrc is

{
  "presets": ["react-native"],
  "plugins": [
    "babel-plugin-transform-decorators-legacy"
  ]
}

Not sure how to solve this problem

@itinance
Copy link
Contributor Author

@Fandekasp this could be also a sign that other dependencies in your node_modules folder could have an own .babelrc

@AdrienLemaire
Copy link

@itinance I indeed had many babelrc files within my dependencies, but removing all of them, then deleting watch logs and resetting cache for react-native start didn't solve the issue

$ find node_modules -name ".babelrc"
node_modules/babel/test/.babelrc
node_modules/babel-plugin-react-transform/.babelrc
node_modules/babel-plugin-react-transform/test/fixtures/code-call-expression-with-render-method/.babelrc
node_modules/babel-plugin-react-transform/test/fixtures/code-class-expression/.babelrc
node_modules/babel-plugin-react-transform/test/fixtures/code-class-extends-react-component/.babelrc
node_modules/babel-plugin-react-transform/test/fixtures/code-class-with-render-method/.babelrc
node_modules/babel-plugin-react-transform/test/fixtures/code-class-within-function/.babelrc
node_modules/babel-plugin-react-transform/test/fixtures/code-class-without-name/.babelrc
node_modules/babel-plugin-react-transform/test/fixtures/code-exports/.babelrc
node_modules/babel-plugin-react-transform/test/fixtures/code-ignore/.babelrc
node_modules/babel-plugin-react-transform/test/fixtures/code-react-create-class/.babelrc
node_modules/babel-plugin-react-transform/test/fixtures/code-react-create-class-with-dynamic-display-name/.babelrc
node_modules/babel-plugin-react-transform/test/fixtures/code-react-create-class-without-display-name/.babelrc
node_modules/babel-plugin-react-transform/test/fixtures/options-custom-factories/.babelrc
node_modules/babel-plugin-react-transform/test/fixtures/options-custom-super-classes/.babelrc
node_modules/babel-plugin-react-transform/test/fixtures/options-multiple-transforms/.babelrc
node_modules/babel-plugin-react-transform/test/fixtures/options-with-imports/.babelrc
node_modules/babel-plugin-react-transform/test/fixtures/options-with-locals/.babelrc
node_modules/escope/.babelrc
node_modules/escope/node_modules/estraverse/.babelrc
node_modules/eslint/node_modules/estraverse/.babelrc
node_modules/jsx-ast-utils/.babelrc
node_modules/node-haste/.babelrc
node_modules/react-native/node_modules/babel-plugin-react-transform/.babelrc
node_modules/react-native/node_modules/babel-plugin-react-transform/test/fixtures/code-call-expression-with-render-method/.babelrc
node_modules/react-native/node_modules/babel-plugin-react-transform/test/fixtures/code-class-expression/.babelrc
node_modules/react-native/node_modules/babel-plugin-react-transform/test/fixtures/code-class-expression-extends-react-component-with-render-method/.babelrc
node_modules/react-native/node_modules/babel-plugin-react-transform/test/fixtures/code-class-extends-component-with-render-method/.babelrc
node_modules/react-native/node_modules/babel-plugin-react-transform/test/fixtures/code-class-extends-react-component/.babelrc
node_modules/react-native/node_modules/babel-plugin-react-transform/test/fixtures/code-class-extends-react-component-with-render-method/.babelrc
node_modules/react-native/node_modules/babel-plugin-react-transform/test/fixtures/code-class-with-render-method/.babelrc
node_modules/react-native/node_modules/babel-plugin-react-transform/test/fixtures/code-class-within-function/.babelrc
node_modules/react-native/node_modules/babel-plugin-react-transform/test/fixtures/code-class-within-function-extends-react-component-with-render-method/.babelrc
node_modules/react-native/node_modules/babel-plugin-react-transform/test/fixtures/code-class-without-name/.babelrc
node_modules/react-native/node_modules/babel-plugin-react-transform/test/fixtures/code-class-without-name-extends-react-component-with-render-method/.babelrc
node_modules/react-native/node_modules/babel-plugin-react-transform/test/fixtures/code-exports/.babelrc
node_modules/react-native/node_modules/babel-plugin-react-transform/test/fixtures/code-ignore/.babelrc
node_modules/react-native/node_modules/babel-plugin-react-transform/test/fixtures/code-react-create-class/.babelrc
node_modules/react-native/node_modules/babel-plugin-react-transform/test/fixtures/code-react-create-class-with-dynamic-display-name/.babelrc
node_modules/react-native/node_modules/babel-plugin-react-transform/test/fixtures/code-react-create-class-with-render-method/.babelrc
node_modules/react-native/node_modules/babel-plugin-react-transform/test/fixtures/code-react-create-class-with-string-literal-display-name/.babelrc
node_modules/react-native/node_modules/babel-plugin-react-transform/test/fixtures/code-react-create-class-with-string-literal-display-name-with-render-method/.babelrc
node_modules/react-native/node_modules/babel-plugin-react-transform/test/fixtures/code-react-create-class-without-display-name/.babelrc
node_modules/react-native/node_modules/babel-plugin-react-transform/test/fixtures/options-custom-factories/.babelrc
node_modules/react-native/node_modules/babel-plugin-react-transform/test/fixtures/options-custom-factories-with-render-method/.babelrc
node_modules/react-native/node_modules/babel-plugin-react-transform/test/fixtures/options-custom-super-classes/.babelrc
node_modules/react-native/node_modules/babel-plugin-react-transform/test/fixtures/options-custom-super-classes-with-render-method/.babelrc
node_modules/react-native/node_modules/babel-plugin-react-transform/test/fixtures/options-multiple-transforms/.babelrc
node_modules/react-native/node_modules/babel-plugin-react-transform/test/fixtures/options-multiple-transforms-with-render-method/.babelrc
node_modules/react-native/node_modules/babel-plugin-react-transform/test/fixtures/options-with-imports/.babelrc
node_modules/react-native/node_modules/babel-plugin-react-transform/test/fixtures/options-with-imports-with-render-method/.babelrc
node_modules/react-native/node_modules/babel-plugin-react-transform/test/fixtures/options-with-locals/.babelrc
node_modules/react-native/node_modules/babel-plugin-react-transform/test/fixtures/options-with-locals-with-render-method/.babelrc
node_modules/react-native-gesture-recognizers/.babelrc

$ rm `find node_modules -name ".babelrc"`
$ watchman watch-del-all
$ react-native start --host 0.0.0.0 -- --reset-cache

Logs

2016-08-29 17:35:05.353 [fatal][tid:com.facebook.React.RCTExceptionsManagerQueue] Unhandled JS Exception: babelHelpers.typeof is not a function. (In 'babelHelpers.typeof(Symbol.iterator)', 'babelHelpers.typeof' is undefined)
2016-08-29 17:35:05.355 [error][tid:com.facebook.React.JavaScript] Module AppRegistry is not a registered callable module.
2016-08-29 17:35:05.357 [fatal][tid:com.facebook.React.RCTExceptionsManagerQueue] Unhandled JS Exception: Module AppRegistry is not a registered callable module.

@itinance
Copy link
Contributor Author

@Fandekasp can you narrow it down that the issue only appears when importing and using this library?

@AdrienLemaire
Copy link

@itinance yes, removing the iap-receipt-validator import statement fixes the issue.

@itinance
Copy link
Contributor Author

itinance commented Aug 29, 2016

@Fandekasp it's like operating in the dark.... what happens when you remove this line https://github.com/sibelius/iap-receipt-validator/blob/master/src/index.js#L1 (i am not sure if this is really needed for this piece of code)

@AdrienLemaire
Copy link

AdrienLemaire commented Aug 29, 2016

@itinance sorry about that, I'm not good with debugging these issues :(

Since the code installed in the node_modules is pure js, I commented the related line require('babel-polyfill');

But the same error keeps happening.

I'll try copy/pasting the es6 code in my project and skip the typeof part as a hack

@AdrienLemaire
Copy link

update: I could successfully verify the receipt by copying and adapting the code without using babel-polyfill and without doing the typeof condition

@EdmundMai
Copy link
Contributor

I'm still seeing this error

@annelorraineuy
Copy link

I got this working by following @Fandekasp's comment. I'll try to make a PR

@annelorraineuy
Copy link

Please check #9

@sibelius
Copy link
Owner

it looks like this facebook/react-native#11093 was merged 3 days ago on react native master branch

@sibelius
Copy link
Owner

let me know if this fix all the problems

new version on npm as well 1.0.6

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants