找不到模块:无法解析“react-leaflet”

Mar*_*gen 3 typescript reactjs react-leaflet

在尝试运行一些示例代码时,我收到编译错误;

"Module not found: Can't resolve 'react-leaflet' in 'C:\Users...\my-app\src\map'"
Run Code Online (Sandbox Code Playgroud)

我正在尝试使用react和typescipt来做到这一点,并使用“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"
  }
Run Code Online (Sandbox Code Playgroud)

小智 7

您还没有添加react-leaflet依赖项,只添加了类型。

运行npm i react-leaflet以安装实际的包。