找不到模块或其相应的类型声明

Cannot find module or its corresponding type declarations

我是 Angular 和 OpenLayers 的初学者,我试图导入一个 geojson 文件,我将它放在资产文件夹中。我还尝试从同一文件夹导入 json 文件,但没有出现任何问题。

import GeoJSON from "ol/format/GeoJSON";
import bundeslandData from 'src/assets/Bundeslandsgrenzen.geojson';
import test from 'src/assets/test.json';

当我尝试这样做时,我收到消息:

Cannot find module 'src/assets/Bundeslandsgrenzen.geojson' or its corresponding type declarations.

我还没有找到任何有类似问题的东西,所以如果有人已经找到解决方案,请 link 它。

Angular 不知道 .geojson 文件并假设它是一个模块。 它知道 .json 并在我们的错误下加载它。 尝试将您的 .geojson 重命名为 .json.