title: How to fix error "Failed to compile : ./node_modules/@react-leaflet/core/esm/path.js 10:41 Module parse failed: Unexpected token (10:41)"
body: <p>I am trying to create a <strong>react-typescript</strong> app along with <strong>leaflet</strong>. I used the command,</p>
  <p><code>npm install leaflet react-leaflet @types/react @types/leaflet --save</code> to install the dependencies.</p>
  <p>But when I start the application it says,</p>
  <pre><code>    ./node_modules/@react-leaflet/core/esm/path.js 10:41
  Module parse failed: Unexpected token (10:41)
  File was processed with these loaders:
   * ./node_modules/babel-loader/lib/index.js
  You may need an additional loader to handle the result of these loaders.
  |   useEffect(function updatePathOptions() {
  |     if (props.pathOptions !== optionsRef.current) {
  &gt;       const options = props.pathOptions ?? {};
  |       element.instance.setStyle(options);
  |       optionsRef.current = options;
  </code></pre>
  <p>Here's my package.json</p>
  <pre><code>{
    &quot;name&quot;: &quot;aq-monitor&quot;,
    &quot;version&quot;: &quot;0.1.0&quot;,
    &quot;private&quot;: true,
    &quot;dependencies&quot;: {
      &quot;@testing-library/jest-dom&quot;: &quot;^5.12.0&quot;,
      &quot;@testing-library/react&quot;: &quot;^11.2.7&quot;,
      &quot;@testing-library/user-event&quot;: &quot;^12.8.3&quot;,
      &quot;@types/jest&quot;: &quot;^26.0.23&quot;,
      &quot;@types/leaflet&quot;: &quot;^1.7.0&quot;,
      &quot;@types/node&quot;: &quot;^12.20.13&quot;,
      &quot;@types/react&quot;: &quot;^17.0.5&quot;,
      &quot;@types/react-dom&quot;: &quot;^17.0.5&quot;,
      &quot;antd&quot;: &quot;^4.15.5&quot;,
      &quot;leaflet&quot;: &quot;^1.7.1&quot;,
      &quot;react&quot;: &quot;^17.0.2&quot;,
      &quot;react-dom&quot;: &quot;^17.0.2&quot;,
      &quot;react-leaflet&quot;: &quot;^3.2.0&quot;,
      &quot;react-router-dom&quot;: &quot;^5.2.0&quot;,
      &quot;react-scripts&quot;: &quot;4.0.3&quot;,
      &quot;typescript&quot;: &quot;^4.2.4&quot;,
      &quot;web-vitals&quot;: &quot;^1.1.2&quot;
    },
    &quot;scripts&quot;: {
      &quot;start&quot;: &quot;react-scripts start&quot;,
      &quot;build&quot;: &quot;react-scripts build&quot;,
      &quot;test&quot;: &quot;react-scripts test&quot;,
      &quot;eject&quot;: &quot;react-scripts eject&quot;
    },
    &quot;eslintConfig&quot;: {
      &quot;extends&quot;: [
        &quot;react-app&quot;,
        &quot;react-app/jest&quot;
      ]
    },
    &quot;browserslist&quot;: {
      &quot;production&quot;: [
        &quot;&gt;0.2%&quot;,
        &quot;not dead&quot;,
        &quot;not op_mini all&quot;
      ],
      &quot;development&quot;: [
        &quot;last 1 chrome version&quot;,
        &quot;last 1 firefox version&quot;,
        &quot;last 1 safari version&quot;
      ]
    },
    &quot;devDependencies&quot;: {
      &quot;@types/react-router-dom&quot;: &quot;^5.1.7&quot;
    }
  }
  </code></pre>
  <p>Here's map/index.tsx</p>
  <pre><code>import React from 'react';
  import './styles.css';
  import L, { LatLngExpression } from &quot;leaflet&quot;;
  import &quot;leaflet/dist/leaflet.css&quot;;
  import {MapContainer, TileLayer, Marker, Popup} from 'react-leaflet';
  
  const position : LatLngExpression = [59.91174337077401, 10.750425582038146];
  
  export default function MapJar() {
      return (
          &lt;MapContainer center={position} zoom={13} scrollWheelZoom={false}&gt;
              &lt;TileLayer
                  attribution='&amp;copy; &lt;a href=&quot;http://osm.org/copyright&quot;&gt;OpenStreetMap&lt;/a&gt; contributors'
                  url=&quot;https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png&quot;
              /&gt;
              &lt;Marker position={position}&gt;
                  &lt;Popup&gt;
                      A pretty CSS3 popup. &lt;br /&gt; Easily customizable.
                  &lt;/Popup&gt;
              &lt;/Marker&gt;
          &lt;/MapContainer&gt;
      );
  }; 
  </code></pre>
  <p>I tried re-installing dependencies several times but still didn't work.</p>
  <p>I understand this is a simple issue and an error that I am making but however, I have not been able to resolve this error.</p>
  <p>Any input is appreciated. Thanks in advance.</p>