title: TypeError: path.join is not a function
body: <p>The code that I have posted is working if I take AWAY the below function that I have wrapped the code with:</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>watcher.on('add', function (path) { 
  });</code></pre>
  </div>
  </div>
  </p>
  
  <p>But if running the below code. I do get this error where path.join is not a function.
  As seen I want to all the time run the code inside watcher.on when a file has been added. The code does react when I add a file but again I always receive below error.
  Do I set up the watcher.on code wrong or what causes the error?</p>
  
  <p><strong>File C:\myproject\instances\b53pd4574z8pe9x793go\New Text Document.txt has been added
  (node:14360) UnhandledPromiseRejectionWarning: TypeError: path.join is not a function</strong></p>
  
  <p>Complete code:</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>'use strict';
  const ccxt = require('ccxt');
  const fs = require('fs');
  const path = require('path');
  var chokidar = require('chokidar');
  var watcher = chokidar.watch('C:/myproject/instances/b53pd4574z8pe9x793go', { ignored: /^\./, persistent: true });
  
  
  var i;
  const exchangename = "binance";
  const exchange = new ccxt.binance({
      'enableRateLimit': false
  });
  
  
  
  watcher.on('add', function (path) {
  (async () =&gt; {
      console.log('File', path, 'has been added')
      const start = Date.now()
  
  
      var orderbookPromises = []
      var symbols = ['ETH/BTC']
      for (i = 0; i &lt; symbols.length; i++) {
  
          const symbol = symbols[i]
          
          try {
                  let tickerProcessing = new Promise(async (resolve) =&gt; {
                      const orderbook = await exchange.fetchOrderBook(symbol, 5)
  
                      const exchangename2 = exchangename + '#' + symbol.replace("/", "")
                      const dumpFile = path.join(__dirname, 'orderbooks', `${exchangename2}Orderbook.txt`)
                  await fs.promises.writeFile(dumpFile, JSON.stringify(orderbook))
                  resolve()
              })
              orderbookPromises.push(tickerProcessing)
  
          } catch (e) {
              console.error(e)
          }
      }
  
      // wait for all of them to execute or fail
      await Promise.all(orderbookPromises)
  
  
      const end = Date.now()
      console.log(`Done in ${(end - start) / 1000} seconds`)
      })()
  });</code></pre>
  </div>
  </div>
  </p>