当我在iOS
中运行我的项目时,我面临提到的错误。根据此SO问题问题必须在babel.config.js
中,
我的babel.config.js
看起来像这样,
module.exports = {
presets: ['module:metro-react-native-babel-preset'],
plugins: [[
"react-native-reanimated/plugin",
"babel-plugin-transform-remove-imports", {
"test": ['react-toastify',
'exceljs',
'file-saver',
/excelutils/,
'react-select',
'react-popover',
'react-router-dom',
'react-pivottable',
'react-chartjs-2',
'react-data-grid',
'chartjs-plugin-colorschemes',
'chartjs-plugin-piechart-outlabels',
'file-saver',
'create-react-class',
'react-dropzone',
/documentuploadmodal/,
/richtextmodal/,
/locationmastermapmodal/]
}
]
]
};
这是我的package.json
"devDependencies": {
"@babel/core": "^7.12.9",
"@babel/runtime": "^7.12.5",
"@react-native-community/eslint-config": "^2.0.0",
"babel-jest": "^26.6.3",
"eslint": "7.14.0",
"jest": "^26.6.3",
"metro-react-native-babel-preset": "^0.66.2",
"react-test-renderer": "17.0.2"
}
我找不到babel.config.js
的任何缺陷。
注意:我只在iOS
中运行时面临此问题。在Android
中工作良好。运行在Xcode 13.2.1
有人能帮我解决这个问题吗?谢谢。
看起来你在一个嵌套数组中包含了两个插件。此外,建议将reanimated放在最后。以下变化:
[
[ 'babel-plugin-transform-remove-imports',
{
test: [ 'react-toastify',
'exceljs',
'file-saver',
/excelutils/,
'react-select',
'react-popover',
'react-router-dom',
'react-pivottable',
'react-chartjs-2',
'react-data-grid',
'chartjs-plugin-colorschemes',
'chartjs-plugin-piechart-outlabels',
'file-saver',
'create-react-class',
'react-dropzone',
/documentuploadmodal/,
/richtextmodal/,
/locationmastermapmodal/ ],
},
],
'react-native-reanimated/plugin',
];