Babel 未知选项:.caller
Babel Unknown option: .caller
当我 运行 npm start babel 抛出以下错误时:ReferenceError: Unknown option: .caller。查看 http://babeljs.io/docs/usage/options/ 了解有关选项的更多信息。
我的package.json:
{
"private": true,
"scripts": {
"start": "node node_modules/react-native/local-cli/cli.js start",
"test": "jest"
},
"dependencies": {
"axios": "^0.18.0",
"moment": "^2.20.1",
"prop-types": "latest",
"react": "^16.5",
"react-native": "^0.57",
"react-native-material-textfield": "^0.12.0",
"react-native-material-ui": "^1.30.1",
"react-native-off-canvas-menu": "^0.1.32",
"react-native-pull-refresh": "^1.0.0",
"react-native-size-matters": "^0.1.4",
"react-native-snackbar": "^0.5.3",
"react-native-snap-carousel": "^3.7.5",
"react-native-vector-icons": "^6.0.2",
"react-navigation": "^2.18.0",
"react-redux": "^5.0.6",
"redux": "^4.0.1",
"redux-persist": "^5.5.0",
"redux-thunk": "^2.2.0",
"ree-validate": "^3.0.2"
},
"devDependencies": {
"@babel/core": "7.0.0-beta.42",
"babel-jest": "23.6.0",
"jest": "23.6.0",
"metro-react-native-babel-preset": "^0.48.1",
"react-test-renderer": "16.5.2"
},
"jest": {
"preset": "react-native"
},
"rnpm": {
"assets": [
"./src/assets/fonts"
]
}
}
我提到我的项目是一个 React Native 应用程序。
我没有对等依赖性错误。我没有发现不同的 babel 依赖项之间有任何冲突。感谢您的帮助。
根据 RN 0.57 更改日志,您需要:
Ensure that you have all the babel dependencies to version ^7.0.0 (you
may also need to add babel-core": "7.0.0-bridge.0" as a yarn
resolution to ensure retro-compatibility)
您似乎有 @babel/core": "7.0.0-beta.42
而不是 ^7.0.0
。
这是在 RN 0.57.1 和 0.57.2 中对我有用的配置:
还要检查 .babelrc
文件是否符合 RN change.log。
在任何时候,如果你遇到一些 babel 错误,你都可以尝试用这样的东西清理所有缓存(使用 yarn 或 npm,取决于你有什么):
rm -rf $TMPDIR/react-* && rm -rf $TMPDIR/metro-* && rm -rf $TMPDIR/haste-* && watchman watch-del-all && rm -rf node_modules && yarn install && npm start -- --reset-cache
当我 运行 npm start babel 抛出以下错误时:ReferenceError: Unknown option: .caller。查看 http://babeljs.io/docs/usage/options/ 了解有关选项的更多信息。
我的package.json:
{
"private": true,
"scripts": {
"start": "node node_modules/react-native/local-cli/cli.js start",
"test": "jest"
},
"dependencies": {
"axios": "^0.18.0",
"moment": "^2.20.1",
"prop-types": "latest",
"react": "^16.5",
"react-native": "^0.57",
"react-native-material-textfield": "^0.12.0",
"react-native-material-ui": "^1.30.1",
"react-native-off-canvas-menu": "^0.1.32",
"react-native-pull-refresh": "^1.0.0",
"react-native-size-matters": "^0.1.4",
"react-native-snackbar": "^0.5.3",
"react-native-snap-carousel": "^3.7.5",
"react-native-vector-icons": "^6.0.2",
"react-navigation": "^2.18.0",
"react-redux": "^5.0.6",
"redux": "^4.0.1",
"redux-persist": "^5.5.0",
"redux-thunk": "^2.2.0",
"ree-validate": "^3.0.2"
},
"devDependencies": {
"@babel/core": "7.0.0-beta.42",
"babel-jest": "23.6.0",
"jest": "23.6.0",
"metro-react-native-babel-preset": "^0.48.1",
"react-test-renderer": "16.5.2"
},
"jest": {
"preset": "react-native"
},
"rnpm": {
"assets": [
"./src/assets/fonts"
]
}
}
我提到我的项目是一个 React Native 应用程序。 我没有对等依赖性错误。我没有发现不同的 babel 依赖项之间有任何冲突。感谢您的帮助。
根据 RN 0.57 更改日志,您需要:
Ensure that you have all the babel dependencies to version ^7.0.0 (you may also need to add babel-core": "7.0.0-bridge.0" as a yarn resolution to ensure retro-compatibility)
您似乎有 @babel/core": "7.0.0-beta.42
而不是 ^7.0.0
。
这是在 RN 0.57.1 和 0.57.2 中对我有用的配置:
还要检查 .babelrc
文件是否符合 RN change.log。
在任何时候,如果你遇到一些 babel 错误,你都可以尝试用这样的东西清理所有缓存(使用 yarn 或 npm,取决于你有什么):
rm -rf $TMPDIR/react-* && rm -rf $TMPDIR/metro-* && rm -rf $TMPDIR/haste-* && watchman watch-del-all && rm -rf node_modules && yarn install && npm start -- --reset-cache