[英]react-native-web: Failed to compile (react-native-vector-icons)
When building react-native-web
, the error below appears:构建
react-native-web
,出现以下错误:
ERROR in ./node_modules/react-native-vector-icons/lib/create-icon-set.js 43:21
Module parse failed: Unexpected token (43:21)
You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders
|
| class Icon extends PureComponent {
> static propTypes = {
| allowFontScaling: PropTypes.bool,
| name: IconNamePropType,
@ ./node_modules/react-native-vector-icons/AntDesign.js 6:0-50 9:16-29
@ ./src/containers/news/index.js
@ ./src/App.js
@ ./src/index.js
And I have this section under .babelrc
file我在
.babelrc
文件下有这个部分
{
"presets": [
"@babel/preset-env",
"@babel/preset-react",
"@babel/preset-typescript",
"module:metro-react-native-babel-preset"
],
"plugins": [
["module-resolver", {
"alias": {
"^react-native$": "react-native-web"
}
}],
"@babel/plugin-transform-runtime",
["@babel/plugin-proposal-class-properties", { "loose": true }]
]
}
Can anyone help ?任何人都可以帮忙吗?
It worked for me moving the .babelrc configuration to the webconfig, the webconfig looks like this它对我将 .babelrc 配置移动到 webconfig 很有用,webconfig 看起来像这样
rules: [
{
test: /\.(js|jsx)$/,
loader: 'babel-loader',
options: {
presets: [
'@babel/preset-env',
"@babel/preset-react",
{
plugins: [
'@babel/plugin-proposal-class-properties'
]
}
]
},
},
{
test: /\.css$/,
loader: 'style-loader!css-loader'
}
]
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.