Module not found: Can't resolve 'esri/Map' When Using @types/arcgis-js-api

3507
3
Jump to solution
11-16-2021 01:52 PM
jpb412
by
New Contributor

Hi,

 

Created a simple react app using Create-React-App, installed the @types/arcgis-js-api following the ts setup instructions in dev portal.  Continue to get Module not found: Can't resolve 'esri/Map' .  Here are the import statements.

 

import EsriMap from 'esri/Map';
import MapView from 'esri/views/MapView';
 
Ive tried deleting node_modules and package-lock.json.  Made sure skipLibCheck : true in the tsconfig.  Tried creating a new project, same result.  Please help.

 

 

0 Kudos
1 Solution

Accepted Solutions
ReneRubalcava
Frequent Contributor

Ok, I see. That doc is for building a pure TypeScript project using the CDN. For create-react-app, you don't need to install the typings. Check out this sample here. It's not in TS, but same rules apply, you can use the default tsconfig from create-react-app and still be ok.

https://github.com/Esri/jsapi-resources/tree/master/esm-samples/jsapi-create-react-app

View solution in original post

3 Replies
ReneRubalcava
Frequent Contributor

Are you using the AMD package arcgis-js-api or the ESM package @arcgis/core?

You don't need the typings installed separately in either case, they’ll  come with the packages. I'm curious what your package.json and project looks like that you need the typings?

0 Kudos
jpb412
by
New Contributor

Hey, thanks for the response.  I should have mentioned that this is a typescript react app.  I basically was just following this from your documentation since I am just getting started with your js sdk.  

https://developers.arcgis.com/javascript/latest/typescript-setup/ 

If its fine to just use the ESM package instead of using the types mentioned in the documentation above I can do that.  Let me know what you suggest.  Thanks.

 

Dependencies from package.json

"dependencies": {
    "@testing-library/jest-dom": "^5.15.0",
    "@testing-library/react": "^11.2.7",
    "@testing-library/user-event": "^12.8.3",
    "@types/arcgis-js-api": "^4.21.0",
    "@types/jest": "^26.0.24",
    "@types/node": "^12.20.37",
    "@types/react": "^17.0.35",
    "@types/react-dom": "^17.0.11",
    "react": "^17.0.2",
    "react-dom": "^17.0.2",
    "react-scripts": "^4.0.3",
    "tslib": "^2.3.1",
    "typescript": "^4.4.4",
    "web-vitals": "^1.1.2"
  }
0 Kudos
ReneRubalcava
Frequent Contributor

Ok, I see. That doc is for building a pure TypeScript project using the CDN. For create-react-app, you don't need to install the typings. Check out this sample here. It's not in TS, but same rules apply, you can use the default tsconfig from create-react-app and still be ok.

https://github.com/Esri/jsapi-resources/tree/master/esm-samples/jsapi-create-react-app