title: ReferenceError: Can't find variable: require when importing Node module in <script> tag
body: <p>Having trouble importing a Node Module using the <code>&lt;script&gt;</code> tag from the HTML.</p>
  <p>Folder structure:</p>
  <pre><code>.
  ├── dist/home.html
  ├── src/html/home.html
  └── node_modules
      └── @group
          ├── sub1/...
          └── sub2/...
              └── src/MyModule.js
  </code></pre>
  <p>The module, &quot;MyModule.js&quot;, uses other sub-packages (e.g. sub1) by using &quot;require&quot; like so:</p>
  <pre><code>const sub1 = require('@group/sub1/x')
  ...
  class MyModule extends XX { ... }
  module.exports = ...
  </code></pre>
  <p>I tried to import it manually like this:</p>
  <pre><code>&lt;script type=&quot;module&quot; src=&quot;/node_modules/@group/sub2/src/MyModule.js&quot;&gt;&lt;/script&gt;
  </code></pre>
  <p>But it results in <code>ReferenceError: Can't find variable: require</code>.</p>
  <p>Is there a solution for this?</p>
  <p><strong>FYI</strong>:</p>
  <ul>
  <li>Gulp is used to build the <code>/dist</code> folder, but an error currently prevents compiling JS files.
  Using <code>&lt;script&gt;</code> is a temporary workaround.</li>
  <li>The module comes with an ES2015 precompiled version (<code>@group/sub2/dist/prebuilt.js</code>), if it helps.</li>
  </ul>