Search code examples
angularopenlayers

Cannot find module or its corresponding type declarations


I'm a beginner with Angular and OpenLayers and I was trying to import a geojson file which i put in the assets folder. I also tried to import a json file from the same folder and had no issues there.

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

When I'm trying to do it like this I'm getting the message:

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

I wasn't able to find anything with a similar issue yet, so if anyone already found a solution please link it.


Solution

  • Angular doesn't know .geojson file and suppose it's a module. It knows .json and load it withour error. Try to rename your .geojson to .json.