如何解决模块解析失败的问题:意外令牌(11:9)react-router-native

时间:2020-04-11 16:15:36

标签: react-native react-router-native

我使用yarn并仅在导入NativeRouter时安装了react-native-router

这是我从react-router-native导入的方式 从“ react-router-native”导入{NativeRouter,Route,Link};

这是我得到的错误

D:/WORKSHOP/Tunga/music-app/node_modules/react-router-native/NativeRouter.js 11:9
Module parse failed: Unexpected token (11:9)
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
|  */
| function NativeRouter(props) {
>   return <MemoryRouter {...props} />;
| }
|

1 个答案:

答案 0 :(得分:3)

有相同的错误。通过添加以下内容进行修复:

"web": {
  "build": {
    "babel": {
      "include": ["react-router-native"]
    }
  }
}

到app.json

来自:source

相关问题