title: Uncaught TypeError: this.method is not a function - Node js class export
body: <p>I am new to node.js and I am trying to require a class. I have used <a href="https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Classes" rel="noreferrer">https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Classes</a> as reference. However, when I do this for example:</p>
  
  <pre><code>// talker.js
  class Talker {
      talk(msg) {
          console.log(this.say(msg))
          var t = setTimeout(this.talk, 5000, 'hello again');
      }
      say(msg) {
          return msg
      }
  }
  export default Talker
  
  // app.js
  import Talker from './taker.js'
  const talker = new Talker()
  talker.talk('hello')
  </code></pre>
  
  <p>I get: </p>
  
  <blockquote>
    <p>talker.js:4 Uncaught TypeError: this.say is not a function</p>
  </blockquote>
  
  <p>It should be said that app.js is the electron.js renderer process and it bundled using rollup.js</p>
  
  <p>Any ideas why this would be?</p>
  
  <p><strong>Update:</strong> Sorry, I forgot to add in a line when putting in the psuedo code. It actually happens when I call <code>setTimeout</code> with callback. I have updated the code.</p>