28

I'm getting the following error from a few different libraries in my project, after adding the "stage-2" preset to my .babelrc. (Thats my assumption atm)

e.g. from the DatePicker class in React Native:

node_modules/react-native/Libraries/Components/DatePickerAndroid/DatePickerAndroid.android.js: You gave us a visitor for the node type "ForAwaitStatement" but it's not a valid type

How can I resolve this error?

I'm using React Native 0.31 and

  "devDependencies": {
    "babel-preset-react-native-stage-0": "^1.0.1",
    "babel-preset-stage-2": "^6.17.0"
  },

6 Answers 6

19

I too ran into this. Solved by updating my babel-core version by changing the entry in package.json to the latest (at the time of this writing)

// package.json
...
"babel-core": "6.17.0",
...

then running

rm -r node_modules/babel* && npm i
3
  • I actually solved this by removing "stage-2" from my .babelrc, turns out I didn't actually need it as React Native supports what I needed. Marking this as the answer as it seems complete.
    – Adamski
    Commented Oct 10, 2016 at 20:26
  • 3
    Even after updating I still had problems. Solved by flushing all babel related modules rm -r node_modules/babel* && npm i. Commented Oct 14, 2016 at 9:04
  • Same issue as @greenimpala. Updating didnt work. Needed to flush all babel modules and reinstall
    – wlingke
    Commented Nov 1, 2016 at 19:13
13

I had the same issue after updating babel-core and some babel plugins. In my case it was fixed by updating babel-cli (globally installed with npm), which was a few versions behind and not using the right babel-core version.

1
  • 2
    it was failing still with "babel-core": "6.17.0", as suggested in the other answer, upgrading babel-cli did the trick.Thanks
    – alfonsodev
    Commented Oct 13, 2016 at 9:59
3

I encountered this after an npm update, struggled for several hours to find a fix, but ultimately solved it via rm -rf node_modules && npm install. I hate npm.

2

I found this issue is caused by a lower version babel-types, so the solution is just:

npm install babel-types

or a clean npm install:

git clean -fdx
npm install
1
  • 1
    This worked for me — bumping all versions didn't do it.
    – jClark
    Commented Oct 17, 2016 at 3:36
1

If your babel-cli is out of date, you might get the same error. Try updateing babel-cli using npm install babel-cli -g or update your local babel-cli and reference it in your package.json scripts. Also do npm i -D babel-plugin-transform-runtime and add "plugins": ["transform-runtime"] to your .babelrc

1

Had a similar situation as @Thomas; a globally installed version of babel-cli which was behind. I can recommend not installing it globally, instead running babel through npm scripts.

Local install: npm install babel-cli --save-dev

In your npm scripts: "babel": "babel script.js"

Not the answer you're looking for? Browse other questions tagged or ask your own question.