<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: @arcgis/core with Next JS Error [ERR_REQUIRE_ESM]: Must use import to load ES Module in ArcGIS JavaScript Maps SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/arcgis-core-with-next-js-error-err-require-esm/m-p/1037988#M72104</link>
    <description>&lt;P&gt;Solved.&amp;nbsp;&lt;A href="https://github.com/benelan/arcgis-esm-samples" target="_blank"&gt;https://github.com/benelan/arcgis-esm-samples&lt;/A&gt;&lt;/P&gt;</description>
    <pubDate>Thu, 18 Mar 2021 12:36:38 GMT</pubDate>
    <dc:creator>Anonymous User</dc:creator>
    <dc:date>2021-03-18T12:36:38Z</dc:date>
    <item>
      <title>@arcgis/core with Next JS Error [ERR_REQUIRE_ESM]: Must use import to load ES Module</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/arcgis-core-with-next-js-error-err-require-esm/m-p/1037947#M72103</link>
      <description>&lt;P&gt;My intention is to use ArcGis API in a Next JS application.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have used `create next app`&amp;nbsp; to create a simple Next JS application.&amp;nbsp;&lt;/P&gt;&lt;P&gt;For this exercise, I used the React sample for reference &lt;A href="https://github.com/Esri/jsapi-resources/tree/master/esm-samples/jsapi-create-react-app" target="_blank"&gt;https://github.com/Esri/jsapi-resources/tree/master/esm-samples/jsapi-create-react-app&lt;/A&gt;&lt;/P&gt;&lt;P&gt;I ran `postinstall` and copied all the assets into the `./public/asset` folder.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I copied the codes in `App.js` from the sample into a script called `map.js` in the `pages` folder. Therefore the exported React component (ArcGisMap) should be viewable at localhost:3000/map in my local dev environment.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I copied the styles from `App.css` from the sample to my `globals.css`&lt;/P&gt;&lt;P&gt;However, I faced this error while loading that page.&amp;nbsp;&lt;/P&gt;&lt;P&gt;`&lt;/P&gt;&lt;P&gt;Error [ERR_REQUIRE_ESM]: Must use import to load ES Module: &lt;A href="mailto:/Users/ming/arcgis-next/my-app/node_modules/@arcgis/core/layers/FeatureLayer.js" target="_blank"&gt;/Users/ming/arcgis-next/my-app/node_modules/@arcgis/core/layers/FeatureLayer.js&lt;/A&gt;&lt;/P&gt;&lt;P&gt;require() of ES modules is not supported.&lt;/P&gt;&lt;P&gt;require() of &lt;A href="mailto:/Users/ming/arcgis-next/my-app/node_modules/@arcgis/core/layers/FeatureLayer.js" target="_blank"&gt;/Users/ming/arcgis-next/my-app/node_modules/@arcgis/core/layers/FeatureLayer.js&lt;/A&gt; from /Users/ming/arcgis-next/my-app/.next/server/pages/map.js is an ES module file as it is a .js file whose nearest parent package.json contains "type": "module" which defines all .js files in that package scope as ES modules.&lt;/P&gt;&lt;P&gt;Instead rename FeatureLayer.js to end in .cjs, change the requiring code to use import(), or remove "type": "module" from &lt;A href="mailto:/Users/ming/arcgis-next/my-app/node_modules/@arcgis/core/package.json" target="_blank"&gt;/Users/ming/arcgis-next/my-app/node_modules/@arcgis/core/package.json&lt;/A&gt;.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; at Object.Module._extensions..js (internal/modules/cjs/loader.js:1080:13)&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; at Module.load (internal/modules/cjs/loader.js:928:32)&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; at Function.Module._load (internal/modules/cjs/loader.js:769:14)&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; at Module.require (internal/modules/cjs/loader.js:952:19)&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; at require (internal/modules/cjs/helpers.js:88:18)&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; at eval (&lt;A href="webpack-internal://@arcgis/core/layers/FeatureLayer:1:18" target="_blank"&gt;webpack-internal:///@arcgis/core/layers/FeatureLayer:1:18&lt;/A&gt;)&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; at &lt;A href="mailto:Object.@arcgis/core/layers/FeatureLayer" target="_blank"&gt;Object.@arcgis/core/layers/FeatureLayer&lt;/A&gt; (/Users/ming/arcgis-next/my-app/.next/server/pages/map.js:137:1)&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; at __webpack_require__ (/Users/ming/arcgis-next/my-app/.next/server/pages/map.js:23:31)&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; at eval (&lt;A href="webpack-internal://./pages/map.js:6:90" target="_blank"&gt;webpack-internal:///./pages/map.js:6:90&lt;/A&gt;)&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; at Module../pages/map.js (/Users/ming/arcgis-next/my-app/.next/server/pages/map.js:104:1)&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; at __webpack_require__ (/Users/ming/arcgis-next/my-app/.next/server/pages/map.js:23:31)&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; at /Users/ming/arcgis-next/my-app/.next/server/pages/map.js:91:18&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; at Object.&amp;lt;anonymous&amp;gt; (/Users/ming/arcgis-next/my-app/.next/server/pages/map.js:94:10)&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; at Module._compile (internal/modules/cjs/loader.js:1063:30)&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; at Object.Module._extensions..js (internal/modules/cjs/loader.js:1092:10)&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; at Module.load (internal/modules/cjs/loader.js:928:32) {&lt;/P&gt;&lt;P&gt;&amp;nbsp; code: 'ERR_REQUIRE_ESM'&lt;/P&gt;&lt;P&gt;}`&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Zhen-MingNgNg_0-1616062335282.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/8750i969C0E393A90CA55/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Zhen-MingNgNg_0-1616062335282.png" alt="Zhen-MingNgNg_0-1616062335282.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;`&lt;/P&gt;</description>
      <pubDate>Thu, 18 Mar 2021 10:17:52 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/arcgis-core-with-next-js-error-err-require-esm/m-p/1037947#M72103</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2021-03-18T10:17:52Z</dc:date>
    </item>
    <item>
      <title>Re: @arcgis/core with Next JS Error [ERR_REQUIRE_ESM]: Must use import to load ES Module</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/arcgis-core-with-next-js-error-err-require-esm/m-p/1037988#M72104</link>
      <description>&lt;P&gt;Solved.&amp;nbsp;&lt;A href="https://github.com/benelan/arcgis-esm-samples" target="_blank"&gt;https://github.com/benelan/arcgis-esm-samples&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 18 Mar 2021 12:36:38 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/arcgis-core-with-next-js-error-err-require-esm/m-p/1037988#M72104</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2021-03-18T12:36:38Z</dc:date>
    </item>
  </channel>
</rss>

