<?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 How to resolve 'undefined Module' error when loading npm package in NodeJS app in ArcGIS JavaScript Maps SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-resolve-undefined-module-error-when-loading/m-p/675628#M62931</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I am trying to load a module called '&lt;A href="https://github.com/uber/geojson2h3"&gt;geojson2h3&lt;/A&gt;' in my `NodeJS` app with the arcgis api for javascript methods to render the hexagons with the &lt;A href="https://github.com/uber/h3-js"&gt;h3&lt;/A&gt; spatial index. After running `npm install geojson2h3` into my node_modules folder, I tried following the initial code instructions given in `Github` to test it out:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;import geojson2h3 from 'geojson2h3';&lt;/P&gt;&lt;P&gt;const polygon = {&lt;BR /&gt;&amp;nbsp; &amp;nbsp; type: 'Feature',&lt;BR /&gt;&amp;nbsp; &amp;nbsp; geometry: {&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; type: 'Polygon',&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; coordinates: [&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; [&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; [-122.47485823276713, 37.85878356045377],&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; [-122.47504834087829, 37.86196795698972],&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; [-122.47845104316997, 37.86010614563313],&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; [-122.47485823276713, 37.85878356045377]&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;]&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;]&lt;BR /&gt;&amp;nbsp; &amp;nbsp; }&lt;BR /&gt; };&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;const hexagons = geojson2h3.featureToH3Set(polygon, 10);&lt;BR /&gt; // -&amp;gt; ['8a2830855047fff', '8a2830855077fff', '8a283085505ffff', '8a283085506ffff']&lt;/P&gt;&lt;P&gt;const feature = geojson2h3.h3SetToFeature(hexagons);&lt;BR /&gt; // -&amp;gt; {type: 'Feature', properties: {}, geometry: {type: 'Polygon', coordinates: [...]}}&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This method throws a `SyntaxError: Cannot use import statement outside a module` error. I then tried using the `NodeJS require` method as such: `const geojson2h3 = require('geojson2h3');`, replacing the `import` statement. This throws an `Uncaught Error: undefinedModule` error. The package shows in my `package.json` filer. What did I do wrong here?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 24 Aug 2020 00:04:06 GMT</pubDate>
    <dc:creator>JustinBridwell2</dc:creator>
    <dc:date>2020-08-24T00:04:06Z</dc:date>
    <item>
      <title>How to resolve 'undefined Module' error when loading npm package in NodeJS app</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-resolve-undefined-module-error-when-loading/m-p/675628#M62931</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I am trying to load a module called '&lt;A href="https://github.com/uber/geojson2h3"&gt;geojson2h3&lt;/A&gt;' in my `NodeJS` app with the arcgis api for javascript methods to render the hexagons with the &lt;A href="https://github.com/uber/h3-js"&gt;h3&lt;/A&gt; spatial index. After running `npm install geojson2h3` into my node_modules folder, I tried following the initial code instructions given in `Github` to test it out:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;import geojson2h3 from 'geojson2h3';&lt;/P&gt;&lt;P&gt;const polygon = {&lt;BR /&gt;&amp;nbsp; &amp;nbsp; type: 'Feature',&lt;BR /&gt;&amp;nbsp; &amp;nbsp; geometry: {&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; type: 'Polygon',&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; coordinates: [&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; [&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; [-122.47485823276713, 37.85878356045377],&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; [-122.47504834087829, 37.86196795698972],&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; [-122.47845104316997, 37.86010614563313],&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; [-122.47485823276713, 37.85878356045377]&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;]&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;]&lt;BR /&gt;&amp;nbsp; &amp;nbsp; }&lt;BR /&gt; };&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;const hexagons = geojson2h3.featureToH3Set(polygon, 10);&lt;BR /&gt; // -&amp;gt; ['8a2830855047fff', '8a2830855077fff', '8a283085505ffff', '8a283085506ffff']&lt;/P&gt;&lt;P&gt;const feature = geojson2h3.h3SetToFeature(hexagons);&lt;BR /&gt; // -&amp;gt; {type: 'Feature', properties: {}, geometry: {type: 'Polygon', coordinates: [...]}}&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This method throws a `SyntaxError: Cannot use import statement outside a module` error. I then tried using the `NodeJS require` method as such: `const geojson2h3 = require('geojson2h3');`, replacing the `import` statement. This throws an `Uncaught Error: undefinedModule` error. The package shows in my `package.json` filer. What did I do wrong here?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 24 Aug 2020 00:04:06 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-resolve-undefined-module-error-when-loading/m-p/675628#M62931</guid>
      <dc:creator>JustinBridwell2</dc:creator>
      <dc:date>2020-08-24T00:04:06Z</dc:date>
    </item>
  </channel>
</rss>

