How to fix error “Failed to compile : ./node_modules/@react-leaflet/core/esm/path.js 10:41 Module parse failed: Unexpected token (10:41)”
https://github.com/PaulLeCam/react-leaflet/issues/877
Answers:
If anyone is having issues with this make sure that your bundling tool is able to handle the nullish coalescing operator.
For babel you can use the @babel/plugin-proposal-nullish-coalescing-operator
. Although make sure that you don't exclude node_modules in the rule. (This should be included in @babel/preset-env
from the documentation)
It is related to facebook/create-react-app#9468 for those using CRA
@Arodriguez14 This is that most people will exclude node_modules when bundling (correctly). This means that the ??
in the project causes issues as the bundler doesn't know what to do with it. If you allow the rule (babel-loader for webpack for example) to run with node_modules too you should be ok (providing you don't need the plugin).
Ideally, this wouldn't be the case. By adding --plugins @babel/plugin-proposal-nullish-coalescing-operator
to the babel cli script that is run when generating the esm module this would mean that your bundler would not need to include this module. @PaulLeCam is this something that could be added?
But if CRA?
I mean sure maybe there is something else? But could also be that CRA is excluding node_modules meaning that it is a similar situation right? Guess what I'm saying is more of an observation rather than the definite solution
facebook/create-react-app#9468 (comment) worked for me
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
· 理解Rust引用及其生命周期标识(上)
· 浏览器原生「磁吸」效果!Anchor Positioning 锚点定位神器解析
· 没有源码,如何修改代码逻辑?
· 分享4款.NET开源、免费、实用的商城系统
· 全程不用写代码,我用AI程序员写了一个飞机大战
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· 白话解读 Dapr 1.15:你的「微服务管家」又秀新绝活了
· 上周热点回顾(2.24-3.2)
2017-07-13 Google Tango service outdated谷歌Tango的服务过时了
2017-07-13 Hello_Motion_Tracking 任务一:Project Tango采集运动追踪数据