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

2874
3
01-04-2022 03:13 AM
ShainaAlia
New Contributor

i am trying to display a map with ArcGis Js Api in ReactJS

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;

but i get the error " Error: Can't resolve '@arcgis/core/MapView' "

i tried to fix the error with re-installing the module @arcgis/core, Webpack and others but i couldn't fix it

can someone help me please ?

0 Kudos
3 Replies
Kishore
Occasional Contributor

@ShainaAlia  - First install the ArcGIS library in the react app folder using 

npm install @arcgis/core

Please follow the blog from @ReneRubalcava  to get the step by step process create-react-app  

Regards,
Kishore
0 Kudos
JoseBanuelos
Esri Contributor

@ShainaAlia ,

The path should be "@arcgis/core/views/MapView" in the MapView import.

Thanks,

Jose

0 Kudos
AzeemIzhar
New Contributor

Your path to MapView incorrect, you miss views directory. Try import MapView from "@arcgis/core/views/MapView"; like in official docs

 
0 Kudos