title: Importing D3 using NPM?
body: <p>I am having trouble getting d3 to import properly after an npm install. The import seems successful with either a d3 download or a script tag as <a href="https://d3js.org/" rel="nofollow noreferrer">per the documentation</a>, but both of these seem like a slight antipattern to me, as I'm used to importing my dependencies with a tool like npm or yarn.</p>
  <p>After running npm install d3 and when trying to import the library, I see the following errors in the browser console after opening my index.html</p>
  <p><a href="https://i.stack.imgur.com/fmbld.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/fmbld.png" alt="enter image description here" /></a></p>
  <p>js1.js</p>
  <pre><code>import d3 from 'd3';
  
  const greetings = function js1(greeting)
  {
      console.log(&quot;Hello from js1&quot; + greeting);
      const selectedelement = d3.select(some_element)
      ...
  
  }
  </code></pre>
  <p>index.html</p>
  <pre><code>&lt;head&gt;
      &lt;script src=&quot;js1.js&quot; type=&quot;text/javascript&quot;&gt;&lt;/script&gt;
  &lt;/head&gt;
  &lt;div&gt;
      &lt;script language=&quot;javascript&quot;&gt;
          greetings(&quot;HALLO&quot;);
      &lt;/script&gt;
  ...
  </code></pre>
  <p>package.json</p>
  <pre><code>...
    &quot;dependencies&quot;: {
      &quot;d3&quot;: &quot;^6.2.0&quot;
    }
  </code></pre>
  <p>package-lock.json</p>
  <pre><code>...
    &quot;dependencies&quot;: {
  ...
      &quot;d3&quot;: {
        &quot;version&quot;: &quot;6.2.0&quot;,
  ...
  </code></pre>