<bdo id='15AmC'></bdo><ul id='15AmC'></ul>
    1. <i id='15AmC'><tr id='15AmC'><dt id='15AmC'><q id='15AmC'><span id='15AmC'><b id='15AmC'><form id='15AmC'><ins id='15AmC'></ins><ul id='15AmC'></ul><sub id='15AmC'></sub></form><legend id='15AmC'></legend><bdo id='15AmC'><pre id='15AmC'><center id='15AmC'></center></pre></bdo></b><th id='15AmC'></th></span></q></dt></tr></i><div id='15AmC'><tfoot id='15AmC'></tfoot><dl id='15AmC'><fieldset id='15AmC'></fieldset></dl></div>
    2. <legend id='15AmC'><style id='15AmC'><dir id='15AmC'><q id='15AmC'></q></dir></style></legend>

      1. <tfoot id='15AmC'></tfoot>

        <small id='15AmC'></small><noframes id='15AmC'>

      2. 如何修复错误“编译失败:./node_modules/@react-leafl

        时间:2023-05-28
          <tbody id='24h9M'></tbody>

        • <bdo id='24h9M'></bdo><ul id='24h9M'></ul>

          1. <legend id='24h9M'><style id='24h9M'><dir id='24h9M'><q id='24h9M'></q></dir></style></legend><tfoot id='24h9M'></tfoot>
                  <i id='24h9M'><tr id='24h9M'><dt id='24h9M'><q id='24h9M'><span id='24h9M'><b id='24h9M'><form id='24h9M'><ins id='24h9M'></ins><ul id='24h9M'></ul><sub id='24h9M'></sub></form><legend id='24h9M'></legend><bdo id='24h9M'><pre id='24h9M'><center id='24h9M'></center></pre></bdo></b><th id='24h9M'></th></span></q></dt></tr></i><div id='24h9M'><tfoot id='24h9M'></tfoot><dl id='24h9M'><fieldset id='24h9M'></fieldset></dl></div>

                  <small id='24h9M'></small><noframes id='24h9M'>

                  本文介绍了如何修复错误“编译失败:./node_modules/@react-leaflet/core/esm/path.js 10:41 模块解析失败:意外令牌(10:41)"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  限时送ChatGPT账号..

                  我正在尝试创建一个 react-typescript 应用程序以及 leaflet.我用了命令,

                  I am trying to create a react-typescript app along with leaflet. I used the command,

                  npm install leaflet react-leaflet @types/react @types/leaflet --save 安装依赖.

                  但是当我启动应用程序时,它说,

                  But when I start the application it says,

                      ./node_modules/@react-leaflet/core/esm/path.js 10:41
                  Module parse failed: Unexpected token (10:41)
                  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.
                  |   useEffect(function updatePathOptions() {
                  |     if (props.pathOptions !== optionsRef.current) {
                  >       const options = props.pathOptions ?? {};
                  |       element.instance.setStyle(options);
                  |       optionsRef.current = options;
                  

                  这是我的 package.json

                  Here's my package.json

                  {
                    "name": "aq-monitor",
                    "version": "0.1.0",
                    "private": true,
                    "dependencies": {
                      "@testing-library/jest-dom": "^5.12.0",
                      "@testing-library/react": "^11.2.7",
                      "@testing-library/user-event": "^12.8.3",
                      "@types/jest": "^26.0.23",
                      "@types/leaflet": "^1.7.0",
                      "@types/node": "^12.20.13",
                      "@types/react": "^17.0.5",
                      "@types/react-dom": "^17.0.5",
                      "antd": "^4.15.5",
                      "leaflet": "^1.7.1",
                      "react": "^17.0.2",
                      "react-dom": "^17.0.2",
                      "react-leaflet": "^3.2.0",
                      "react-router-dom": "^5.2.0",
                      "react-scripts": "4.0.3",
                      "typescript": "^4.2.4",
                      "web-vitals": "^1.1.2"
                    },
                    "scripts": {
                      "start": "react-scripts start",
                      "build": "react-scripts build",
                      "test": "react-scripts test",
                      "eject": "react-scripts eject"
                    },
                    "eslintConfig": {
                      "extends": [
                        "react-app",
                        "react-app/jest"
                      ]
                    },
                    "browserslist": {
                      "production": [
                        ">0.2%",
                        "not dead",
                        "not op_mini all"
                      ],
                      "development": [
                        "last 1 chrome version",
                        "last 1 firefox version",
                        "last 1 safari version"
                      ]
                    },
                    "devDependencies": {
                      "@types/react-router-dom": "^5.1.7"
                    }
                  }
                  

                  这里是 map/index.tsx

                  Here's map/index.tsx

                  import React from 'react';
                  import './styles.css';
                  import L, { LatLngExpression } from "leaflet";
                  import "leaflet/dist/leaflet.css";
                  import {MapContainer, TileLayer, Marker, Popup} from 'react-leaflet';
                  
                  const position : LatLngExpression = [59.91174337077401, 10.750425582038146];
                  
                  export default function MapJar() {
                      return (
                          <MapContainer center={position} zoom={13} scrollWheelZoom={false}>
                              <TileLayer
                                  attribution='&copy; <a href="http://osm.org/copyright">OpenStreetMap</a> contributors'
                                  url="https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png"
                              />
                              <Marker position={position}>
                                  <Popup>
                                      A pretty CSS3 popup. <br /> Easily customizable.
                                  </Popup>
                              </Marker>
                          </MapContainer>
                      );
                  }; 
                  

                  我尝试了几次重新安装依赖项,但仍然没有成功.

                  I tried re-installing dependencies several times but still didn't work.

                  我知道这是一个简单的问题和我正在犯的错误,但是我无法解决此错误.

                  I understand this is a simple issue and an error that I am making but however, I have not been able to resolve this error.

                  感谢任何输入.提前致谢.

                  Any input is appreciated. Thanks in advance.

                  推荐答案

                  我找到了解决方法.

                  修复步骤:-

                  打开您的 package.json 文件并编辑您的浏览器列表,如下所示.

                  Open your package.json file and edit your browserslist as follows.

                   "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 目录.

                  Once you've done this, Delete node_modules/.cache directory.

                  那就试试npm install

                  npm start

                  Tadaaa!

                  参考:-

                  • https://github.com/facebook/create-react-app/issues/9468#issuecomment-694191642
                  • https://github.com/PaulLeCam/react-leaflet/issues/877

                  这篇关于如何修复错误“编译失败:./node_modules/@react-leaflet/core/esm/path.js 10:41 模块解析失败:意外令牌(10:41)"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:刷新传单地图:地图容器已经初始化 下一篇:我可以防止将传单地图平移出世界边缘吗?

                  相关文章

                  最新文章

                • <legend id='hUXEh'><style id='hUXEh'><dir id='hUXEh'><q id='hUXEh'></q></dir></style></legend>

                      <i id='hUXEh'><tr id='hUXEh'><dt id='hUXEh'><q id='hUXEh'><span id='hUXEh'><b id='hUXEh'><form id='hUXEh'><ins id='hUXEh'></ins><ul id='hUXEh'></ul><sub id='hUXEh'></sub></form><legend id='hUXEh'></legend><bdo id='hUXEh'><pre id='hUXEh'><center id='hUXEh'></center></pre></bdo></b><th id='hUXEh'></th></span></q></dt></tr></i><div id='hUXEh'><tfoot id='hUXEh'></tfoot><dl id='hUXEh'><fieldset id='hUXEh'></fieldset></dl></div>
                    1. <small id='hUXEh'></small><noframes id='hUXEh'>

                      • <bdo id='hUXEh'></bdo><ul id='hUXEh'></ul>
                    2. <tfoot id='hUXEh'></tfoot>