Reputation: 37
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"
}
Upvotes: 3
Views: 17037
Reputation: 29
I changed the dependencies of react app by decreasing them like below my dependency :
{
"name": "app",
"version": "0.1.0",
"private": true,
"dependencies": {
"@reduxjs/toolkit": "^2.2.3",
"@testing-library/jest-dom": "^5.17.0",
"@testing-library/react": "^13.4.0",ß
"@testing-library/user-event": "^13.5.0",
"axios": "^1.7.9",
"bootstrap": "^5.3.3",
"js-cookie": "^3.0.5",
"leaflet": "^1.8.0",
"react": "^18.3.1",
"react-bootstrap": "^2.10.4",
"react-dom": "^18.3.1",
"react-leaflet": "^4.2.1",
"react-redux": "^9.1.2",
"react-router": "^6.24.1",
"react-router-dom": "^6.24.1",
"react-scripts": "5.0.1",
"react-toastify": "^10.0.6",
"web-vitals": "^2.1.4"
},
"scripts": {
"start": "react-scripts start",
"build": " react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
},
"eslintConfig": {
"extends": [
"react-app",
"react-app/jest"
]
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
},
"devDependencies": {
"@types/leaflet": "^1.9.15"
}
}
Upvotes: 0
Reputation: 41
npm i leaflet
Run this command also in terminal and it will work
Upvotes: 3
Reputation: 86
You haven't added the react-leaflet dependency, only the types.
Run npm i react-leaflet
to install the actual package.
Upvotes: 7