-
Notifications
You must be signed in to change notification settings - Fork 889
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Can't compile react-leaflet #891
Comments
Having the same issue, related thread in create-react-app: facebook/create-react-app#9468 (comment) Picked up a lot of activity in the last ~20 days. See last comments for remarks from react guys. |
`Failed to compile. ./node_modules/@react-leaflet/core/esm/path.js 10:41
| element.instance.setStyle(options); the same issue |
`Failed to compile. ./node_modules/@react-leaflet/core/esm/pane.js 2:27
|
`Failed to compile. ./node_modules/@react-leaflet/core/esm/layer.js 8:46
| container.addLayer(element.instance); ` |
`Failed to compile. ./node_modules/react-leaflet/esm/Pane.js 25:37
` |
`Failed to compile. ./node_modules/react-leaflet/esm/MapContainer.js 72:30
` |
I assume this is can be treated as critical.. |
how this is not fixed asap ? |
Same issue... |
Exactly the same problem. This seems to be a problem that keeps on giving in some form or fashion without a consistent resolution. |
This issue can be reproduced with next.js as well.
|
Paul Cammy fucked up when he released react-leaflet@3.2.0. He broke all event handling related to task popup open/close so nothing works anymore. He also broke compilation: PaulLeCam/react-leaflet#891
Ok somewhere else in internet, I found following fix:
|
This doesn't resolve the issue, and also isn't working for everybody. Create React App, for example, expects a different structure. You'll discover this if you read the referenced issues. Don't close this ticket! |
Changing the browser target is a stupid workaround but not a fix. It's also not necessary for any of the other probably thousands of packages in a typical project. |
This has already been addressed here: A quick fix is to downgrade Leaflet. In your package.json file, change these lines:
Then remove the node_modules folder and run Optional: |
new "progressive" style '??' should be replaced with old style '?:' in 5 places which I posted above for quickfix. |
Com' on, it's only one line hope so , why nobody fixing this? |
Same issue trying to import vis-data. Module parse failed: Unexpected token (1437:21)
File was processed with these loaders:
* ../../node_modules/react-scripts/node_modules/babel-loader/lib/index.js
You may need an additional loader to handle the result of these loaders.
| if (id != null) {
| // a single item
> return item ?? null;
| } else {
| // just return our array |
I fixed this upgrading to webpack 5, if it helps somebody. |
I've been trying to run it on Next.js, but it didn't work. |
any update on this issue? using create-react-app. I am happy to make a PR if I can get some guidance 😅 |
No clean solution so farBut this workaround works for me without eject!
|
this answer worked for me |
this solution is the fastest |
Please use the +1 icon (👍) at the top of the issue instead of writing "me too". Repo owners can find popular tickets that way. Comments are made for discussing the issue. |
Hi 🙂 In my case I had to use a webpack rule with the following packages as quoted above :
As you can see, I only include react-leaflet that was causing trouble. Context : PWA Studio (based on React). |
Fix this please. It's ridiculous. |
For Next.js 11 do two following things to make the latest version (react-leaflet@3.2.1) work for you:
const withTM = require("next-transpile-modules")([
"react-leaflet/node_modules/@react-leaflet/core", // specifying just the "react-leaflet" won't work
]);
const DynamicMap = dynamic(() => import("../../src/components/map/Map"), { ssr: false });
const MapPage = () => {
return (
<DynamicMap />
);
}; |
In order to run it, the react-leaflet library must be downgraded. These are the steps:
You can now run the client doing npm start. |
I find it shocking that telling it to target old browsers fixes this. The issue started occuring for me when I changed "browserslist": {
"production": [
"last 2 Chrome versions",
"last 2 Firefox versions",
"last 2 Safari versions",
"iOS >= 13",
"unreleased versions"
],
"development": [
"last 2 Chrome versions",
"last 2 Firefox versions",
"last 10 Safari versions",
"iOS >= 13",
"unreleased versions"
]
} to "browserslist": {
"production": [
"last 2 Chrome versions",
"last 2 Firefox versions",
"last 2 Safari versions",
"iOS >= 14",
"unreleased versions"
],
"development": [
"last 2 Chrome versions",
"last 2 Firefox versions",
"last 2 Safari versions",
"iOS >= 14",
"unreleased versions"
]
} |
This lib needs a new maintainer that understands the issue. |
Why close an issue that hasn’t been fixed? |
Hit this error while working. Only known fix at present is to downgrade react-leaflet and @react-leaflet/core. PaulLeCam/react-leaflet#891
This issue is still blocking may people from using the package. It should not be closed indeed. |
Still having this issue. |
Come on... please, respect the open-source reputation. |
Guys i fixed this issue by forking repo and changing babel.js config. I really think, this fix should exist in react leaftlet as it blocks the usage |
It is not always easy to change the babel, and it is super ugly in 2022 to add something in babel for just a dependency. |
|
I faced the same issue and was able to resolve it by importing the files separately import { MapContainer } from 'react-leaflet/MapContainer'
import { TileLayer } from 'react-leaflet/TileLayer'
import { useMap } from 'react-leaflet/hooks' |
same issue now 🥺 |
Same issue (4.2.1) I was able to fix it by using the exact imports. ( |
Add “use client” to the top of your file. "use client" NextJS assumes a component is a Server Component unless you explicitly tell NextJS the component you want is a Client Component. |
I also encountered this problem and solved it in a clumsy way! Since umijs is used as the development framework, configuring babel plugins is extremely inconvenient, so I gave up. Finally, I found the source code of react-leaflet from the node_modules directory. I copied the js files under the two directories of /lib and /node_modules/@react-leaflet/core/lib into my own code project. Files with the suffix.d.ts don't need to be copied. Then, I modified the copied code, corrected the import path. Finally, I deleted the react-leaflet configuration in package.json and ran npm uninstall. Then it was all right. |
Out of all the alleged solutions, this answer worked for me. To expand on the answer, I tweaked mine a bit to something akin to this:
|
Bug report
Can't compile blank react app after adding react-leaflet. Throws following error:
`
`
Expected behavior
Should compile and be able to use react leaflet
Steps to reproduce
Edit
For me #891 (comment) this resolved issue, but comments below indicate it's not working for everybody. Please try this and check if it's working for you or not.
The text was updated successfully, but these errors were encountered: