首页 > 解决方案 > npm run build 在构建 react-native 模块(react-native-stars)时给出 Ionic React 的语法错误

问题描述

我收到以下错误:

> react-scripts build                                                   
> Creating an optimized production build...                             
> Failed to compile.                                                    
> ./node_modules/react-native-stars/index.js                            
> SyntaxError:
> /mnt/c/linux_share/ayelho-mockup/node_modules/react-native-stars/index.js:
> Unexpected token (35:8)                                               
> 33 |     return this.props.opacity ?                                  
> 34 |       this.isReactElement(this.props.fullStar) ?                 
> > 35 |         <View style={{opacity: partial}}>                                                                             
> >    |         ^
> 36 |           {this.props.fullStar}                                  
> 37 |         </View>                                                  
> 38 |         :

我试过使用 react-native-star-rating 并且这给出了类似的错误(它失败了)。所以这可能是我的设置中的东西。我需要做些什么来告诉它这是一个标签吗?

主应用程序是用打字稿编写的。

标签: node.jsreactjsreact-native

解决方案


推荐阅读