'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 1:[1]
You haven't added the react-leaflet dependency, only the types.
Run npm i react-leaflet to install the actual package.
Solution 2:[2]
npm i leaflet
Run this command also in terminal and it will work
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Nobonex |
| Solution 2 | Muhammad Saqlain |
