How to fix error Failed to compile : ./node_modules/@react-leaflet/core/esm/path.js 10:41 Module parse failed: Unexpected token (10:41)
I found a way to fix it.
Steps to fix:
Open your package.json file and edit your browserslist as follows.
From ?? Operator results in "Unexpected Token" err when used in package #9468:
Once you've done this, delete theto"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
},"browserslist": [
">0.2%",
"not dead",
"not op_mini all"
],
node_modules/.cache
directory.Then try npm install
.
And npm start
Tadaaa!
References:
- ?? Operator results in "Unexpected Token" err when used in package #9468
- Module parse failed: Unexpected token (10:41) in @react-leaflet/core/esm/path.js #877
Module parse failed: additional babel_loader
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 react-leaflet@3.1.0 @react-leaflet/core@1.0.2
You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file.
You are using unnecessary escape character: which is not required.
Replace test: '/\.(js|jsx)$/',
with test: /\.js$|jsx/,
it should work fine.
I replicated your issue in my machine and found the same which is resolved by the above fix.
hope this helps, happy coding!!!
Related Topics
Basic Ajax Send/Receive with Node.Js
Adding a Slide Effect to Bootstrap Dropdown
Why Does a Simple .*? Non-Greedy Regex Greedily Include Additional Characters Before a Match
Counting Frequency of Characters in a String Using JavaScript
How to Show Current Time in JavaScript in the Format Hh:Mm:Ss
Passing Data to a Jquery UI Dialog
Single Quote Escape in JavaScript Function Parameters
How to Upload Preview Image Before Upload Through JavaScript
Why Does JavaScript's Regex.Exec() Not Always Return the Same Value
How to Auto-Reload Files in Node.Js
Professional Jquery Based Combobox Control
Insert Text at Cursor in a Content Editable Div
JavaScript Remove "Disabled" Attribute from HTML Input
Overriding Interface Property Type Defined in Typescript D.Ts File
Initializing Select with Angularjs and Ng-Repeat
Logical Operator || in JavaScript, 0 Stands for Boolean False
How to Use Jquery to Style /Parts/ of All Instances of a Specific Word