I have been using react-leaflet for a while now, and after a few weeks I deleted the files inside the node_modules and reinstalled them, and I did not touch the react-leaflet version at all, but when I try to run the project, it gives me an error.
./node_modules/@react-leaflet/core/esm/path.js 10:41 Module parse failed: Unexpected token (10:41) File was processed with these loaders:
const options = props.pathOptions ?? {};
| element.instance.setStyle(options); | optionsRef.current = options;
In order to run it, the react-leaflet library must be downgraded. These are the steps:
remove react-leaflet: npm uninstall react-leaflet
update your react-scripts version to 3.3.0 or higher: npm install --save react-scripts@latest
remove node_module directory (optional)
clean cache:
npm cache clean --force
Install the working versions:
npm i [email protected] @react-leaflet/[email protected]
You can now run the client doing npm start.