title: How to properly export a class as a module in Node.js
body: <p>I have <strong>class A</strong> and <strong>class B</strong>, and <strong>class A</strong> extends <strong>class B</strong>.</p>
  
  <p>But they are in different files. Now in my 'server.js' I want to use <strong>class A</strong>.</p>
  
  <p>My code in <code>a.js</code> is written as this:</p>
  
  <pre><code>const B = require('./b.js');
  
  module.exports = class A extends B {}
  </code></pre>
  
  <p>But it gave me an error on line 2 at symbol <code>B</code> saying:</p>
  
  <p><em>TypeError: Class extends value #<code>&lt;Object&gt;</code> is not a function or null</em></p>
  
  <p>How to properly export a class which extends another class in Node.js?</p>