Search code examples
reactjstypescriptreact-leaflet

Module not found: Can't resolve 'react-leaflet'


While trying to run some example code, I get a compilation error;

"Module not found: Can't resolve 'react-leaflet' in 'C:\Users...\my-app\src\map'"

I'm trying to do this with react and typescipt, and use "react-leaflet"

I've already tried installing both types@react-leaflet and react-leaflet

Here are my dependencies:

"dependencies": {
    "@types/jest": "24.0.15",
    "@types/leaflet": "^1.4.4",
    "@types/node": "12.0.8",
    "@types/react": "16.8.20",
    "@types/react-dom": "16.8.4",
    "@types/react-leaflet": "^2.2.1",
    "leaflet": "^1.5.1",
    "react": "^16.8.6",
    "react-dom": "^16.8.6",
    "react-scripts": "3.0.1",
    "save": "^2.4.0",
    "typescript": "3.5.2"
  }

Solution

  • You haven't added the react-leaflet dependency, only the types.

    Run npm i react-leaflet to install the actual package.