title: Why does this module return undefined?
body: <p>I'm writting a code in NodeJs using jimp and qrcode-reader. Those dependencies work well. The issue lies when I export the code into a module. And supposedly, it should return a value. This is an arrow function that returns the URL of the QR Code. However, If I use &quot;console.log&quot;, I can see it works. But when I use the module, it returns undefined. Perhaps I'm missing something real simple.</p>
  <p>Here is the code of the module:</p>
  <pre><code>const Jimp = require('jimp')
  const fs = require('fs')
  const QrCode = require('qrcode-reader')
  
  const scanQR = (source) =&gt; {
  const buffer = fs.readFileSync(source)
  
     Jimp.read(buffer, (err, image) =&gt; {
         try {
             const qr = new QrCode()
             qr.callback = (error, value) =&gt; {
                 try {
                     console.log(value.result)
                     return value.result
                 } catch(error) {
                     console.error(error)
                 }
             }
             qr.decode(image.bitmap)
         } catch (error) {
             console.error(error)
         }
     })
  }
  
  module.exports = scanQR
  </code></pre>
  <p>Here is the module imported:</p>
  <pre><code>const scanQR = require('./utils/scanQR')
  const qr_code_screenshot = `${__dirname}/assets/images/qrcode-test.png`
  const result = scanQR(qr_code_screenshot)
  console.log(result)
  </code></pre>
  <p>Here is the result on console:
  <a href="https://i.stack.imgur.com/T6OoT.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/T6OoT.png" alt="Console result" /></a></p>
  <p>Thanks in advance.</p>