尝试运行示例代码时,出现编译错误;
"Module not found: Can't resolve 'react-leaflet' in 'C:\Users...\my-app\src\map'"
我正在尝试使用react和typecipt来做到这一点,并使用“ react-leaflet”
我已经尝试过同时安装types @ react-leaflet和react-leaflet
这是我的依赖项:
"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"
}
答案 0 :(得分:3)
您尚未添加react-leaflet依赖关系,仅添加了类型。
运行npm i react-leaflet
以安装实际的软件包。
答案 1 :(得分:0)
npm i leaflet
也在终端中运行此命令,它将起作用