How to fix " Error: Can't resolve '@arcgis/core/MapView' "

How to fix " Error: Can't resolve '@arcgis/core/MapView' "

我正在尝试在 ReactJS 中使用 ArcGis Js Api 显示地图

import Map from "@arcgis/core/Map";
import WebMap from "@arcgis/core/WebMap";
import MapView from "@arcgis/core/MapView";


function Test() {

    const webmap = new WebMap({
        portalItem: {
          id: "e691172598f04ea8881cd2a4adaa45ba"
        }
      });
      
      /************************************************************
       * Set the WebMap instance to the map property in a MapView.
       ************************************************************/
      const view = new MapView({
        map: webmap,
        container: "viewDiv"
      });

    return(

        <div>
            <div id="viewDiv"></div>
        </div>

    )
  };
  

  export default Test;

但我收到错误消息“错误:无法解析‘@arcgis/core/MapView’”

我试图通过重新安装模块@arcgis/core、Webpack 和其他模块来修复错误,但我无法修复它

有人可以帮我吗?

MapView 的路径不正确,您错过了 views 目录。像 official docs

一样尝试 import MapView from "@arcgis/core/views/MapView";