New react-native app has 'TypeError: babelHelp

2019-02-05 19:43发布

A new project created with the latest version of react-native throws javascript error while running(/debugging). Tested this on simulator.

[fatal][tid:main] TypeError: babelHelpers.typeof is not a function. (In 'babelHelpers.typeof(target)', 'babelHelpers.typeof' is undefined)

Installed the react-native client today & created the app using

react-native init AwesomeProject

App version:

react-native-cli: 0.1.10
react-native: 0.20.0
node version: v5.6.0

7条回答
虎瘦雄心在
2楼-- · 2019-02-05 20:09

To solve the problem, I renamed a .babelrc file in a parent directory, then ran ./node_modules/react-native/packager/packager.sh start --reset-cache

查看更多
家丑人穷心不美
3楼-- · 2019-02-05 20:17

I updated to the newly released react-native@0.21 and the issue went away. I am not sure if this means the root issue has been resolved since I have seen intermittent success with other "fixes".

查看更多
Melony?
4楼-- · 2019-02-05 20:22

Solved adding babel stage-1 and react-native preset's to .babelrc in the project's root folder.

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

More details here: https://github.com/facebook/react-native/issues/5747

查看更多
贪生不怕死
5楼-- · 2019-02-05 20:26

One issue is that if there is a .babelrc in a parent directory to your app, the packager will read that and it will cause this exact error. One way around it is to add a .babelrc file in your project:

{
  "presets": ["react-native"]
}
查看更多
唯我独甜
6楼-- · 2019-02-05 20:27

Double check your import path/file names as they are case sensitive

查看更多
冷血范
7楼-- · 2019-02-05 20:28

It's usually due to a 3rd party npm dependency that has .babelrc or babel es2015 preset specified in it's package.json.

There's a fix in place: https://github.com/facebook/react-native/pull/11093

查看更多
登录 后发表回答