title: req.file.stream is undefined
body: <p>I'm having troubles with node 16 and ES6. I'm trying to make a upload file controller but i'm stuck with req.file.stream which is undefined
  I'm using multer to handle upload files.</p>
  <p>The first issue was  __dirname undefined that I was able to fix  with path and New Url.</p>
  <p>The error I got with pipeline</p>
  <pre><code>node:internal/process/promises:246
            triggerUncaughtException(err, true /* fromPromise */);
            ^
  
  TypeError [ERR_INVALID_ARG_TYPE]: The &quot;source&quot; argument must be of type function or an instance of Stream, Iterable, or AsyncIterable. Received undefined
  </code></pre>
  <p>my userRoutes.js</p>
  <pre><code>import express from &quot;express&quot;;
  import { signin, signup, logout } from &quot;../Controller/AuthController.js&quot;;
  import {
    getUsers,
    getUser,
    updateUser,
    deleteUser,
    follow,
    unfollow,
  } from &quot;../Controller/UserController.js&quot;;
  import { upload } from &quot;../Controller/UploadController.js&quot;;
  import multer from &quot;multer&quot;;
  
  const router = express.Router();
  // Auth
  router.post(&quot;/signin&quot;, signin);
  router.post(&quot;/signup&quot;, signup);
  router.post(&quot;/logout&quot;, logout);
  
  // users
  router.get(&quot;/&quot;, getUsers);
  router.get(&quot;/:id&quot;, getUser);
  router.patch(&quot;/:id&quot;, updateUser);
  router.delete(&quot;/:id&quot;, deleteUser);
  router.patch(&quot;/follow/:id&quot;, follow);
  router.patch(&quot;/unfollow/:id&quot;, unfollow);
  
  // upload
  router.post(&quot;/upload&quot;, multer().single(&quot;file&quot;), upload);
  export default router;
  
  </code></pre>
  <p>And my UploadController.js</p>
  <pre><code>
  import fs from &quot;fs&quot;;
  import { promisify } from &quot;util&quot;;
  import stream from &quot;stream&quot;;
  
  const pipeline = promisify(stream.pipeline);
  // const { uploadErrors } = require(&quot;../utils/errors.utils&quot;);
  import path from &quot;path&quot;;
  const __dirname = path.dirname(new URL(import.meta.url).pathname);
  
  export const upload = async (req, res) =&gt; {
    try {
      // console.log(req.file);
      console.log(__dirname);
      if (
        !req.file.mimetype == &quot;image/jpg&quot; ||
        !req.file.mimetype == &quot;image/png&quot; ||
        !req.file.mimetype == &quot;image/jpeg&quot;
      )
        throw Error(&quot;invalid file&quot;);
  
      if (req.file.size &gt; 2818128) throw Error(&quot;max size&quot;);
    } catch (err) {
      const errors = uploadErrors(err);
      return res.status(201).json({ err });
    }
    const fileName = req.body.name + &quot;.jpg&quot;;
    await pipeline(
      req.file.stream,
      fs.createWriteStream(
        `${__dirname}/../client/public/uploads/profil/${fileName}`
      )
    );
  
    try {
      await User.findByIdAndUpdate(
        req.body.userId,
        { $set: { picture: &quot;./uploads/profil/&quot; + fileName } },
        { new: true, upsert: true, setDefaultsOnInsert: true },
        (err, docs) =&gt; {
          if (!err) return res.send(docs);
          else return res.status(500).send({ message: err });
        }
      );
    } catch (err) {
      return res.status(500).send({ message: err });
    }
  };
  </code></pre>