简体   繁体   English

反应 leaflet 模块解析失败:意外令牌 (10:39)

[英]react leaflet Module parse failed: Unexpected token (10:39)

Failed to compile.

./node_modules/@react-leaflet/core/lib/path.js 10:39 ./node_modules/@react-leaflet/core/lib/path.js 10:39
Module parse failed: Unexpected token (10:39) You may need an appropriate loader to handle this file type.模块解析失败:意外令牌 (10:39) 您可能需要适当的加载程序来处理此文件类型。 | | useEffect(function updatePathOptions() { | if (props.pathOptions.== optionsRef.current) { useEffect(function updatePathOptions() { | if (props.pathOptions.== optionsRef.current) {

 var options = props.pathOptions?? {};

| | element.instance.setStyle(options); element.instance.setStyle(options); | | optionsRef.current = options; optionsRef.current = 选项;

I had the same problem.我有同样的问题。 After some research, I found the below answers, which helped me fix them.经过一番研究,我找到了以下答案,这有助于我解决它们。

  1. First, check if your react version matches "react-leaflet" version.首先,检查您的反应版本是否与“react-leaflet”版本匹配。
    • For example in "react-leaflet" version 4.x, React v18 and Leaflet v1.8 are now required as peer dependency.例如,在“react-leaflet”版本 4.x 中,现在需要 React v18 和 Leaflet v1.8 作为对等依赖项。 ref. 参考。
  2. Update browserslist in package.json to this:package.json中的browserslist更新为:
...    
    "browserslist": [
       ">0.2%",
      "not dead",
      "not op_mini all"
    ],
...
  1. Delete .cache directory in node_modules and start over.删除node_modules中的.cache目录并重新开始。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM