title: How to setup javascript threejs library with node.js
body: <p>My problem is that I had been working with threejs 3 years ago, and I remember that when you had to include the library you had to use:</p>
  <pre class="lang-html prettyprint-override"><code>&lt;script src=&quot;cdn-router-threejs&quot;&gt;&lt;/script&gt;
  </code></pre>
  <p>But now in the documentation they use another way to import the library: <strong>npm</strong></p>
  <p>Acording to that I follow all steps:</p>
  <ol>
  <li><p>Install node.js (<code>node -v</code> response <code>v12.16.3</code>)</p>
  </li>
  <li><p>Create a folder for my project (threejs-example)</p>
  </li>
  <li><p>Inside the folder I execute <code>npm init</code> to setup my project in my folder. By default <em>package-json</em> file my main script is called <em>index.js</em>.</p>
  </li>
  <li><p>Execute <code>npm install --save three</code> to download the libraries</p>
  </li>
  <li><p>In <em>index.js</em> insert the lines:</p>
  <pre class="lang-js prettyprint-override"><code>import * as THREE from 'three';
  const scene = new THREE.Scene();
  </code></pre>
  </li>
  <li><p>I don't know how to continue from this point. I have tried:</p>
  <ul>
  <li><p>a) I write in my <em>index.html</em></p>
  <pre class="lang-html prettyprint-override"><code>&lt;script type=&quot;module&quot; defer src=&quot;index.js&quot;&gt;&lt;/script&gt;
  </code></pre>
  <p>But that option doesn't work.</p>
  </li>
  <li><p>b) I have tried to create a bundle with the library <code>webpack</code> and <code>browserify</code> but I wasn't successful.</p>
  </li>
  </ul>
  <p>In the case of <code>browserify</code> I type:</p>
  <pre class="lang-none prettyprint-override"><code>npm install -g browserify
  browserify index.js -o bundle.js
  </code></pre>
  <p>And I get the following error:</p>
  <p><a href="https://i.stack.imgur.com/cmaY5.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/cmaY5.png" alt="error when i type browserify index.js -o bundle.js" /></a></p>
  <p>In the case of <code>webpack</code>: Dont really know how to do it.</p>
  </li>
  </ol>
  <p>Any advise would be appreciated. Thank you in advanced</p>