我的反应本机代码直到昨天都运行良好,但今天当我试图编译代码时,我遇到了这个奇怪的错误。
node /Users/aragorn/relay-react-native-app/node_modules/react-native/local-cli/cli.js bundle --entry-file index.ios.js --platform ios --dev true --reset-cache --bundle-output check.js
[04/23/2017, 18:48:40] <START> Initializing Packager
[04/23/2017, 18:48:49] <START> Building Haste Map
[04/23/2017, 18:48:50] <END> Building Haste Map (751ms)
[04/23/2017, 18:48:50] <END> Initializing Packager (9888ms)
[04/23/2017, 18:48:50] <START> Transforming files
Warning: The transform cache was reset.
TransformError: /Users/aragorn/relay-react-native-app/index.ios.js: Unexpected token import.
以下是我添加的 .babelrc 文件,因为我需要添加,因为我正在使用带有 react-native 的中继。
{
"passPerPreset": true,
"presets": [
{
"plugins": [
"./plugins/babelRelayPlugin"
]
},
"react-native"
]
}
我为此苦苦挣扎了一段时间。有人可以帮忙吗?
另外,我在 package.json 中添加了所有 babel 依赖项:-
"devDependencies": {
"babel-jest": "18.0.0",
"babel-preset-react-native": "1.9.1",
"babel-cli": "6.18.0",
"babel-core": "6.21.0",
"babel-relay-plugin": "0.10.0",
"jest": "18.0.0",
"react-test-renderer": "15.4.1",
"babel-eslint": "7.1.1",
"eslint": "3.13.1",
"eslint-config-eslint": "3.0.0",
"eslint-friendly-formatter": "2.0.7",
"eslint-loader": "1.6.1",
"eslint-plugin-import": "2.2.0",
"eslint-plugin-jsx-a11y": "3.0.2",
"eslint-plugin-react": "6.9.0"
},