我在使用react-map-gl库时遇到模块解析器错误
./node_modules/react-map-gl/dist/esm/components/use-control.js 12:46
Module parse failed: Unexpected token (12:46)
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.
|
| if (!map.hasControl(ctrl)) {
> map.addControl(ctrl, (opts || onRemove)?.position);
| }
|
我正在尝试使用 Mapbox 进行地图集成,但在运行代码时遇到上述错误,有人知道这个问题吗?请帮助我
./node_modules/react-map-gl/dist/esm/components/use-control.js 12:46
Module parse failed: Unexpected token (12:46)
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.
|
| if (!map.hasControl(ctrl)) {
> map.addControl(ctrl, (opts || onRemove)?.position);
| }
|
I am trying to use Mapbox for Map integration but I am getting above error while running the code, is anybody aware of this issue please help me
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我遇到了同样的问题。对我来说,将反应脚本从 ^4.0.3 升级到 ^5.0.0
"react-scripts": "^5.0.0"
I ran into this same exact problem. What did it for me was upgrading react-scripts from ^4.0.3 to ^5.0.0
"react-scripts": "^5.0.0"
您需要转译react-map-gl lib。
同样的方法,https://moti.fyi/web
该解决方案也可用于@gorhom/bottom-sheet。
试试这个。
webpack.config.js
同样的问题。
React 模块解析失败 – react-map-gl
You need to transpile react-map-gl lib.
Same approach, https://moti.fyi/web
This solution can be used for @gorhom/bottom-sheet also.
Try this.
webpack.config.js
Same question.
React Module Parse Failed – react-map-gl