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

[0.19][ios]Error 'babelHelpers.typeof is not a function' running examples UIExplorer #5747

Closed
asd123freedom opened this issue Feb 4, 2016 · 89 comments
Assignees
Labels
Resolution: Locked This issue was locked by the bot.

Comments

@asd123freedom
Copy link

The project I inited before run normally. But the example cloned from react-native of github could not works. I followed the steps in README, and I find out one module require babel@5.8.29 when I run 'npm install'.
I assume that the error occurs because of the version of babel. But I can not solve the problem by install latest version of babel.

@facebook-github-bot
Copy link
Contributor

Hey asd123freedom, thanks for reporting this issue!

React Native, as you've probably heard, is getting really popular and truth is we're getting a bit overwhelmed by the activity surrounding it. There are just too many issues for us to manage properly.

  • If you don't know how to do something or something is not working as you expect but not sure it's a bug, please ask on StackOverflow with the tag react-native or for more real time interactions, ask on Discord in the #react-native channel.
  • If this is a feature request or a bug that you would like to be fixed, please report it on Product Pains. It has a ranking feature that lets us focus on the most important issues the community is experiencing.
  • We welcome clear issues and PRs that are ready for in-depth discussion. Please provide screenshots where appropriate and always mention the version of React Native you're using. Thank you for your contributions!

@gijoehosaphat
Copy link

@asd123freedom I also got this upon upgrading. I tried clearing babel cache and the react native packager cache. It wasn't until I literally rebooted that it was resolved.

Not the most concrete solution I understand, but this is eventually what solved it for me. I suspect there was something being cached somewhere in $TMP but couldn't track it down.

@asd123freedom
Copy link
Author

@gijoehosaphat Thanks a lot. I will try it as soon as possible. By the way, the way of cleaning cache is remove related files in '/tmp', isn't it?

@skevy
Copy link
Contributor

skevy commented Feb 4, 2016

@asd123freedom @gijoehosaphat the best way to make sure the packager cache is cleared is by doing:

$ watchman watch-del-all
$ [packager command] --reset-cache

@niftylettuce
Copy link
Contributor

For me, the fix was getting rid of es2015 as a preset in my .babelrc file, thanks @skevy

@bestander
Copy link
Contributor

@gijoehosaphat was the problem solved?

@gijoehosaphat
Copy link

I ended up not having to change any code in the project, and continue to use stage-0, es2015 and react babel presets. I believe it was just cache causing a conflict.

@bestander
Copy link
Contributor

cc @asd123freedom good to close?

@asd123freedom
Copy link
Author

@bestander Because of Chinese new year I am in a vacation not having my mac aside. I will try the solution @gijoehosaphat suggested when I come back from vacation. So it's good to close. Thanks a lot.

@bestander
Copy link
Contributor

👍 reopen if it is still an issue

@mikepugh
Copy link

I'm now running into this issue with v0.19.0, so I tried upgrading to v0.20.0 but I still run into the issue.

Newly init'd projects work fine, but a project I started about a week ago is broken. I've tried all of the above suggestions with no luck.

This morning I've done the following:
rm -rf node_modules/
watchman watch-del-all
npm cache clean
I then removed all dev and regular dependencies from package.json except for react-native@0.20.0
npm install
react-native run-ios

And it still comes up with the undefined babelHelpers.typeof exception.

I was able to take my application specific code and basically dump that into a newly init'd project and it runs fine. I'd still like to know why my original repo is hosed though, and fix if possible.

@bestander
Copy link
Contributor

what does your package.json look like?

@mikepugh
Copy link

I took it down to its bare minimum, trying to replicate a fresh react-native init.

{
  "name": "testApp",
  "version": "0.0.1",
  "private": true,
  "scripts": {
    "start": "node node_modules/react-native/local-cli/cli.js start",    
  },
  "dependencies": {
    "react-native": "0.20.0"    
  }
}

Previously there was more (See below), but I spent several hours adding and removing package dependencies to try and figure out if one of them was the problem. One step I did take last night was to react-native init a new app, and then one by one add the dependencies seen below and after each one I ran the simulator. I was able to get my app running in the simulator this way, so I'm at a loss for what might be the root cause in my original repo folder.

{
  "name": "testApp",
  "version": "0.0.1",
  "private": true,
  "scripts": {
    "start": "node node_modules/react-native/local-cli/cli.js start",
    "remotedev": "remotedev --hostname=localhost --port=8000",
    "test": "mocha --compilers js:babel-register --require  ./test/test_helper.js --require babel-polyfill --recursive || true"
  },
  "dependencies": {
    "firebase": "2.4.0",
    "geofire": "3.2.4",
    "history": "2.0.0",
    "immutable": "3.7.6",
    "ramda": "0.19.1",
    "react-addons-pure-render-mixin": "0.14.7",
    "react-native": "0.20.0",
    "react-native-drawer": "1.15.0",
    "react-native-geocoder": "0.3.1",
    "react-native-maps": "0.3.0",
    "react-native-router-flux": "2.2.0",
    "react-redux": "4.4.0",
    "redux": "3.3.1",
    "redux-saga": "0.7.0",
    "redux-thunk": "1.0.3",
    "reselect": "2.0.3"
  },
  "jscsConfig": {
    "maximumLineLength": null
  },
  "devDependencies": {
    "babel-cli": "6.5.1",
    "babel-plugin-transform-regenerator": "6.5.2",
    "babel-polyfill": "6.5.0",
    "babel-preset-es2015": "6.5.0",
    "babel-register": "6.5.2",
    "chai": "3.5.0",
    "chai-immutable": "1.5.3",
    "mocha": "2.4.5",
    "remote-redux-devtools": "0.1.2",
    "remotedev-server": "0.0.3"
  }
}

@Kureev
Copy link
Contributor

Kureev commented Feb 19, 2016

@mikepugh

$ npm cache clean

is something different from

[packager command] --reset-cache

Try to run

$ ./node_modules/react-native/packager/packager.sh start --resetCache

from your application folder first.

UPD: Also, I'd like to see your .babelrc file. If you're using 0.20.0, there are some fixes you probably should make.

@mikepugh
Copy link

@Kureev - ok thanks for the tip, I'll try that out once I'm back on that machine this afternoon.

I don't have a .babelrc file, I did have a "babel" section within package.json which loaded the es2015 preset, but it's missing at the moment due to all of the recent meddling.

@mikepugh
Copy link

@Kureev awesome - the --reset-cache fixed it.

@Kureev
Copy link
Contributor

Kureev commented Feb 19, 2016

@mikepugh I'm glad it helped you.

@prasanthu
Copy link

I have the same problem for a fresh clean project created the project using
react-native init

http://stackoverflow.com/questions/35563025/new-react-native-app-has-typeerror-babelhelpers-typeof-is-not-a-function-ios

@lifehackett
Copy link

I've tried all the above suggestions and am still running into this problem. Uncaught TypeError: babelHelpers.typeof is not a function
Node v4.3.1
NPM v3.7.3

I've been running
npm run reset
node node_modules/react-native/local-cli/cli.js run-ios --reset-cache

{
  "name": "mobile_moderation",
  "version": "0.0.1",
  "private": true,
  "scripts": {
    "remotedev": "remotedev --hostname=localhost --port=8000",
    "reset": "rm -rf node_modules/ && npm cache clear && watchman watch-del-all && rm -rf $TMPDIR/react-* && npm i",
    "start": "node node_modules/react-native/local-cli/cli.js start --reset-cache",
    "test": "mocha --compilers js:babel-core/register --require ./test/test-helper.js --recursive",
    "test:watch": "npm run test -- --watch --watch-extensions jsx"
  },
  "babel": {
    "presets": [
      "es2015",
      "stage-2"
    ],
    "plugins": [
      "transform-regenerator",
      "transform-flow-strip-types"
    ]
  },
  "dependencies": {
    "immutable": "^3.7.6",
    "ramda": "^0.19.1",
    "react": "^0.14.7",
    "react-native": "^0.20.0",
    "react-redux": "^4.4.0",
    "redux": "^3.3.1",
    "redux-saga": "^0.8.2",
    "reselect": "^2.0.3"
  },
  "devDependencies": {
    "babel-cli": "^6.5.1",
    "babel-core": "^6.5.2",
    "babel-plugin-transform-flow-strip-types": "^6.5.0",
    "babel-plugin-transform-regenerator": "^6.5.2",
    "babel-polyfill": "^6.5.0",
    "babel-preset-es2015": "^6.5.0",
    "babel-preset-stage-2": "^6.5.0",
    "chai": "^3.5.0",
    "chai-immutable": "^1.5.3",
    "mocha": "^2.4.5",
    "remotedev-server": "0.0.3"
  }
}

@xuezhma
Copy link

xuezhma commented Feb 25, 2016

@prasanthu @lifehackett
I was just having the same problem.
What I did were:

$npm uninstall -g react-native-cli
$brew update && brew upgrade
$npm install -g react-native-cli

I'm at

$ node -v
v5.6.0
$ react-native -v
react-native-cli: 0.1.10
react-native: 0.20.0

@desamtralized
Copy link

Did what @xuezhma told but it didn't fixed for me, any other solution? Thanks!

@Kureev
Copy link
Contributor

Kureev commented Feb 25, 2016

@lifehackett @sambarboza Can you please share your .babelrc configs? (if you already tried to run a packager with --reset-cache option)

@desamtralized
Copy link

@Kureev are these .babelrc configs global or per project? On the project folder I don't have this file. I've tried to run the packager command with --reset-cache.

@lifehackett
Copy link

@Kureev I wasn't using a .babelrc config in my original post. The babel transforms were applied in my package.json #5747 (comment)

I have tried this setup as well and gotten the same results.

.babelrc

{
    "extends": "react-native/packager/react-packager/.babelrc"
}

package.json

{
  "name": "TestProject",
  "version": "0.0.1",
  "private": true,
  "scripts": {
    "remotedev": "remotedev --hostname=localhost --port=8000",
    "reset": "rm -rf node_modules/ && npm cache clear && watchman watch-del-all && rm -rf $TMPDIR/react-* && npm i",
    "start": "node node_modules/react-native/local-cli/cli.js start --reset-cache & sudo dtruss -fn node",
    "test": "mocha --compilers js:babel-core/register --require ./test/test-helper.js --recursive",
    "test:watch": "npm run test -- --watch --watch-extensions jsx"
  },
  "dependencies": {
    "immutable": "^3.7.6",
    "ramda": "^0.19.1",
    "react": "^0.14.7",
    "react-native": "^0.20.0",
    "react-redux": "^4.4.0",
    "redux": "^3.3.1",
    "redux-saga": "^0.8.2",
    "reselect": "^2.0.3"
  },
  "devDependencies": {
    "babel-cli": "^6.5.1",
    "babel-plugin-transform-flow-strip-types": "^6.5.0",
    "babel-plugin-transform-regenerator": "^6.5.2",
    "babel-preset-es2015": "^6.5.0",
    "babel-preset-stage-2": "^6.5.0",
    "chai": "^3.5.0",
    "chai-immutable": "^1.5.3",
    "mocha": "^2.4.5",
    "remote-redux-devtools": "^0.1.2",
    "remotedev-server": "0.0.3"
  }
}

@Kureev
Copy link
Contributor

Kureev commented Feb 25, 2016

@lifehackett you shouldn't extend react-native's babelrc file (since 0.20). Try using this https://github.com/facebook/react-native/tree/master/babel-preset instead of es2015.

You can also check a list of transforms react-native preset gives you.

@lifehackett
Copy link

@Kureev Same result

@desamtralized
Copy link

@lifehackett @Kureev same thing here.

@JAStanton
Copy link
Contributor

I had been running into this issue for the last few days, just solved this by switching the es2015 preset from my .babelrc with react-native and then running react-native start --reset-cache. My .babelrc file looks like this now:

{
  "presets": ["stage-1", "stage-2", "stage-3", "react-native"],
  "plugins": ["transform-decorators-legacy"],
}

and my package.json looks like this:

{
  "private": true,
  "name": "[REDACTED]",
  "version": "0.0.0",
  "scripts": {
    "authenticate": "scripts/authenticate",
    "bundle": "scripts/bundle:js",
    "bundle:js": "scripts/bundle:js",
    "clean": "scripts/clean:cache && scripts/clean:deps",
    "clean:cache": "scripts/clean:cache",
    "clean:deps": "scripts/clean:deps",
    "postinstall": "scripts/postinstall",
    "provision": "scripts/provision",
    "publish": "scripts/publish",
    "publish:all": "scripts/publish demo && scripts/publish production",
    "publish:sourcemap": "scripts/publish:sourcemap",
    "publish:codepush": "scripts/publish:codepush",
    "shrinkwrap": "npm-shrinkwrap",
    "start": "scripts/start",
    "start:ios": "scripts/start:ios",
    "test": "mocha --require babel/register"
  },
  "dependencies": {
    "google-libphonenumber": "1.0.7",
    "js-quantities": "1.6.0",
    "lodash": "3.10.1",
    "moment-timezone": "0.4.1",
    "numeral": "1.5.3",
    "pluralize": "1.2.1",
    "raven-js": "1.3.0",
    "react-addons-shallow-compare": "0.14.0",
    "react-addons-update": "0.14.0",
    "react-mixin": "3.0.0",
    "react-native": "0.20.0",
    "react-native-audioplayer": "0.2.0",
    "react-native-background-geolocation": "0.3.3",
    "react-native-code-push": "1.7.3-beta",
    "react-native-file-upload": "1.0.4",
    "react-native-image-picker": "marcshilling/react-native-image-picker#5720a18",
    "react-native-mixpanel": "0.0.7",
    "react-native-orientation": "JAStanton/react-native-orientation#340a0ba",
    "react-native-scrollable-tab-view": "0.3.7",
    "react-native-side-menu": "0.18.0",
    "react-native-vector-icons": "1.2.1",
    "react-timer-mixin": "0.13.3",
    "redux": "3.3.1",
    "redux-thunk": "1.0.3",
    "shallowequal": "0.2.2",
    "url": "0.11.0"
  },
  "devDependencies": {
    "babel-plugin-transform-decorators-legacy": "1.3.4",
    "babel-preset-react-native": "1.4.0",
    "babel-preset-stage-1": "6.5.0",
    "babel-preset-stage-2": "6.5.0",
    "babel-preset-stage-3": "6.5.0",
    "code-push-cli": "1.5.0-beta",
    "ios-sim": "5.0.6",
    "mocha": "2.3.3",
    "react-native-cli": "0.1.10",
    "sinon": "1.17.1"
  }
}

I am on node-version: v4.1.0
I am on npm version: 2.14.3
I installed all my dependencies with npm3 install.

@Kureev
Copy link
Contributor

Kureev commented Feb 25, 2016

@JAStanton I already recommended @lifehackett and @sambarboza to replace es2015 by react-native preset and clear the cache, but seems they have the same problem still.

P.S. You can remove stage-2 and stage-3 from your config, stage-1 includes 2nd and 3rd stages by default

@jd327
Copy link

jd327 commented Oct 6, 2016

@jeffgran this is what I get when searching for .babelrc:

./node_modules/babel-preset-react-native/node_modules/babel-plugin-react-transform/.babelrc

(everything else is either in "test" or "lint" folders, I'm guessing those don't count?)

@jeffgran
Copy link

Huh. I don't know. My issue definitely seemed to be resolved when I figured out that multiple (incompatible) .babelrc files were being picked up. Maybe there are multiple causes of this issue.

@hellogerard
Copy link

Interestingly, I came here because I started getting this error after installing my npm dependencies with yarn. Using npm works fine. Installing with yarn, and then running my React Native project results in this error.

@jd327
Copy link

jd327 commented Oct 12, 2016

@hellogerard same. Tested yarn, it didn't install everything properly, went back to npm. Too new.

@Simek
Copy link
Collaborator

Simek commented Oct 21, 2016

When this will be fixed or fix will be shipped/merged?

@lacker
Copy link
Contributor

lacker commented Dec 17, 2016

At this point this thread appears to be a number of unrelated issues globbed together with the original one fixed. I am going to close this issue and encourage people who still have something similar to open a new issue with repro steps that are specific to their app. Thanks folks!

@lacker lacker closed this as completed Dec 17, 2016
facebook-github-bot pushed a commit that referenced this issue Dec 20, 2016
Summary:
We started encountering the error described in #5747 (`babelHelpers.typeof is not a function) after switching from npm to yarn. [This comment](#5747 (comment)) led to [this comment](#4844 (comment)) which contains a solution we've been using successfully in our production app.

Maybe I didn't look in the right place but it doesn't seem anyone had actually PR'd this change before (if so and I didn't find it, I apologize).

An alternative solution it seems is to add a [different .babelrc](http://stackoverflow.com/questions/35563025/new-react-native-app-has-typeerror-babelhelpers-typeof-is-not-a-function-ios), but this seems easier to me.
Closes #11093

Differential Revision: D4353977

fbshipit-source-id: 3e45de29ef5d0e046219a32df6530dcf838b9fd9
mikelambert pushed a commit to mikelambert/react-native that referenced this issue Dec 24, 2016
Summary:
We started encountering the error described in facebook#5747 (`babelHelpers.typeof is not a function) after switching from npm to yarn. [This comment](facebook#5747 (comment)) led to [this comment](facebook#4844 (comment)) which contains a solution we've been using successfully in our production app.

Maybe I didn't look in the right place but it doesn't seem anyone had actually PR'd this change before (if so and I didn't find it, I apologize).

An alternative solution it seems is to add a [different .babelrc](http://stackoverflow.com/questions/35563025/new-react-native-app-has-typeerror-babelhelpers-typeof-is-not-a-function-ios), but this seems easier to me.
Closes facebook#11093

Differential Revision: D4353977

fbshipit-source-id: 3e45de29ef5d0e046219a32df6530dcf838b9fd9
nicktate pushed a commit to nicktate/react-native that referenced this issue Dec 30, 2016
Summary:
We started encountering the error described in facebook#5747 (`babelHelpers.typeof is not a function) after switching from npm to yarn. [This comment](facebook#5747 (comment)) led to [this comment](facebook#4844 (comment)) which contains a solution we've been using successfully in our production app.

Maybe I didn't look in the right place but it doesn't seem anyone had actually PR'd this change before (if so and I didn't find it, I apologize).

An alternative solution it seems is to add a [different .babelrc](http://stackoverflow.com/questions/35563025/new-react-native-app-has-typeerror-babelhelpers-typeof-is-not-a-function-ios), but this seems easier to me.
Closes facebook#11093

Differential Revision: D4353977

fbshipit-source-id: 3e45de29ef5d0e046219a32df6530dcf838b9fd9
mikelambert pushed a commit to mikelambert/react-native that referenced this issue Jan 4, 2017
Summary:
We started encountering the error described in facebook#5747 (`babelHelpers.typeof is not a function) after switching from npm to yarn. [This comment](facebook#5747 (comment)) led to [this comment](facebook#4844 (comment)) which contains a solution we've been using successfully in our production app.

Maybe I didn't look in the right place but it doesn't seem anyone had actually PR'd this change before (if so and I didn't find it, I apologize).

An alternative solution it seems is to add a [different .babelrc](http://stackoverflow.com/questions/35563025/new-react-native-app-has-typeerror-babelhelpers-typeof-is-not-a-function-ios), but this seems easier to me.
Closes facebook#11093

Differential Revision: D4353977

fbshipit-source-id: 3e45de29ef5d0e046219a32df6530dcf838b9fd9
DanielMSchmidt pushed a commit to DanielMSchmidt/react-native that referenced this issue Jan 4, 2017
Summary:
We started encountering the error described in facebook#5747 (`babelHelpers.typeof is not a function) after switching from npm to yarn. [This comment](facebook#5747 (comment)) led to [this comment](facebook#4844 (comment)) which contains a solution we've been using successfully in our production app.

Maybe I didn't look in the right place but it doesn't seem anyone had actually PR'd this change before (if so and I didn't find it, I apologize).

An alternative solution it seems is to add a [different .babelrc](http://stackoverflow.com/questions/35563025/new-react-native-app-has-typeerror-babelhelpers-typeof-is-not-a-function-ios), but this seems easier to me.
Closes facebook#11093

Differential Revision: D4353977

fbshipit-source-id: 3e45de29ef5d0e046219a32df6530dcf838b9fd9
alehlopeh added a commit to alehlopeh/wintershell that referenced this issue Jan 6, 2017
cpojer pushed a commit to facebook/metro that referenced this issue Jan 26, 2017
Summary:
We started encountering the error described in #5747 (`babelHelpers.typeof is not a function) after switching from npm to yarn. [This comment](facebook/react-native#5747 (comment)) led to [this comment](facebook/react-native#4844 (comment)) which contains a solution we've been using successfully in our production app.

Maybe I didn't look in the right place but it doesn't seem anyone had actually PR'd this change before (if so and I didn't find it, I apologize).

An alternative solution it seems is to add a [different .babelrc](http://stackoverflow.com/questions/35563025/new-react-native-app-has-typeerror-babelhelpers-typeof-is-not-a-function-ios), but this seems easier to me.
Closes facebook/react-native#11093

Differential Revision: D4353977

fbshipit-source-id: 3e45de29ef5d0e046219a32df6530dcf838b9fd9
@yordis
Copy link

yordis commented Feb 1, 2017

@lacker I am having this exact issue.

Log
babelHelpers.typeof is not a function. (In 'babelHelpers.typeof(target)', 'babelHelpers.typeof' is undefined)

.babelrc

{
"presets": ["env","react-native"],
"plugins": [],
"sourceMaps": true
}

Deps

    "react": "~15.4.0-rc.4",
    "react-native": "0.40.0",
    "react-native-checkbox": "^1.1.0",
    "react-native-elements": "^0.9.2",
    "react-native-vector-icons": "^4.0.0"
  },
  "devDependencies": {
    "babel-cli": "^6.22.2",
    "babel-eslint": "^7.1.1",
    "babel-jest": "18.0.0",
    "babel-preset-env": "^1.1.8",
    "babel-preset-react-native": "1.9.1",
    "eslint": "^3.14.0",
    "eslint-config-react-native": "^1.6.0",
    "eslint-plugin-flowtype": "^2.30.0",
    "flow-bin": "^0.36.0",
    "jest": "18.1.0",
    "react-test-renderer": "~15.4.0-rc.4"
  }

@erichua23
Copy link

In my case, i forget to set presets in .babelrc, add "react-native" as preset in .babelrc works

@justinmoon
Copy link

I just encountered this problem when adding the a dependency called redux-query.

Changing the redux-query .babelrc from:

{
    "presets": ["react", "es2015", "stage-2"]
}

To:

{
    "presets": ["react", "react-native", "stage-2"]
}

Made problem go away.

@facebook facebook locked as resolved and limited conversation to collaborators Jul 20, 2018
@react-native-bot react-native-bot added the Resolution: Locked This issue was locked by the bot. label Jul 20, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Resolution: Locked This issue was locked by the bot.
Projects
None yet
Development

No branches or pull requests