Search code examples
react-nativereact-router-native

How can I solve the Module parse failed: Unexpected token (11:9) react-router-native


I installed react-native-router using yarn and just on importing NativeRouter

This is how I import from react-router-native import { NativeRouter, Route, Link } from "react-router-native";

This is the error I get

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} />;
| }
|

Solution

  • Had the same error. Fixed by adding:

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

    to app.json

    From: source