未安装react-leaflet库

时间:2018-02-23 06:16:52

标签: reactjs react-leaflet

当我尝试导入库“react-leaflet”时,我收到此错误:

ERROR in ./node_modules/react-leaflet/lib/propTypes/map.js
Module not found: Error: Can't resolve 'leaflet' in 'D:\PycharmProjects\adminora\node_modules\react-leaflet\lib\propTypes'
@ ./node_modules/react-leaflet/lib/propTypes/map.js 5:15-33
@ ./node_modules/react-leaflet/lib/Map.js
@ ./node_modules/react-leaflet/lib/index.js

编辑:我的package.json文件:

  "dependencies": {
    "@types/react": "^16.0.36",
    "babel-polyfill": "^6.26.0",
    "classnames": "^2.2.5",
    "history": "^4.7.2",
    "jwt-decode": "^2.2.0",
    "material-ui": "^1.0.0-beta.27",
    "material-ui-icons": "^1.0.0-beta.17",
    "prop-types": "^15.6.0",
    "react": "^16.2.0",
    "react-block-ui": "^1.1.1",
    "react-dom": "^16.2.0",
    "react-leaflet": "^1.8.1",
  }

2 个答案:

答案 0 :(得分:1)

您还需要安装依赖包,尝试使用

npm install leaflet prop-types react react-dom react-leaflet

答案 1 :(得分:0)

删除node_modules文件夹和package-lock.json文件,然后尝试以下命令。

npm install
npm install react-leaflet --save