3

我已经使用 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 你可能需要一个额外的加载器来处理这些加载器的结果。| useEffect(function updatePathOptions() { | if (props.pathOptions !== optionsRef.current) {
  const options = props.pathOptions ?? {};

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


4

1 回答 1

6

为了运行它,必须降级 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 的客户端。

于 2021-06-17T10:57:20.940 回答