【问题标题】:Module parse failed: additional babel_loader模块解析失败:附加 babel_loader
【发布时间】:2021-09-02 01:28:35
【问题描述】:

我已经使用 react-leaflet 有一段时间了,几周后我删除了 node_modules 中的文件并重新安装了它们,我根本没有接触 react-leaflet 版本,但是当我尝试运行时该项目,它给了我一个错误。


./node_modules/@react-leaflet/core/esm/path.js 10:41 模块解析失败:意外令牌 (10:41) 使用这些加载器处理了文件:

  • ./node_modules/react-scripts/node_modules/babel-loader/lib/index.js 您可能需要一个额外的加载器来处理这些加载器的结果。 |使用效果(函数更新路径选项(){ | if (props.pathOptions !== optionsRef.current) {
  const options = props.pathOptions ?? {};

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


【问题讨论】:

标签: reactjs leaflet react-leaflet babel-loader react-leaflet-v3


【解决方案1】:

要运行它,必须降级 react-leaflet 库。 步骤如下:

  1. 删除反应传单:npm uninstall react-leaflet

  2. 将您的 react-scripts 版本更新到 3.3.0 或更高版本:npm install --save react-scripts@latest

  3. 删除 node_module 目录(可选)

  4. 清理缓存: npm cache clean --force

  5. 安装工作版本: npm i react-leaflet@3.1.0 @react-leaflet/core@1.0.2

您现在可以通过 npm start 运行客户端。

【讨论】:

    猜你喜欢
    • 2016-05-30
    • 1970-01-01
    • 2018-06-01
    • 1970-01-01
    • 2020-08-16
    • 1970-01-01
    • 2020-06-24
    • 2017-06-01
    • 2016-05-05
    相关资源
    最近更新 更多