找不到模块:无法解析 'react-leaflet'
Module not found: Can't resolve 'react-leaflet'
在尝试 运行 一些示例代码时,出现编译错误;
"Module not found: Can't resolve 'react-leaflet' in 'C:\Users...\my-app\src\map'"
我正在尝试使用 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"
}
您还没有添加 react-leaflet 依赖项,只添加了类型。
运行 npm i react-leaflet
安装实际包。
npm i leaflet
运行 这个命令也在终端中,它会起作用
在尝试 运行 一些示例代码时,出现编译错误;
"Module not found: Can't resolve 'react-leaflet' in 'C:\Users...\my-app\src\map'"
我正在尝试使用 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"
}
您还没有添加 react-leaflet 依赖项,只添加了类型。
运行 npm i react-leaflet
安装实际包。
npm i leaflet
运行 这个命令也在终端中,它会起作用