---
title: "Comment by Dean Tarisai on \"What REALLY happens when we require() a module in NodeJS?\" | Hashnode"
description: "Awesome post! But what causes an error to rise when I try to use an .mjs file inside of a js file ? Are they limits to interoperability of module formats ?"
url: "https://hashnode.com/posts/what-really-happens-when-we-require-a-module-in-nodejs/63a8f90a1ba9a9c0dc2a6927/comment/63a924878de4e0eeae64f01d"
---

[Discussion](https://hashnode.com/posts/what-really-happens-when-we-require-a-module-in-nodejs/63a8f90a1ba9a9c0dc2a6927)

Comment [What REALLY happens when we require() a module in NodeJS?](https://hashnode.com/posts/what-really-happens-when-we-require-a-module-in-nodejs/63a8f90a1ba9a9c0dc2a6927)

[Dean Tarisai](https://hashnode.com/@deantarisai)

[Dec 26, 2022](https://hashnode.com/posts/what-really-happens-when-we-require-a-module-in-nodejs/63a8f90a1ba9a9c0dc2a6927/comment/63a924878de4e0eeae64f01d)

Awesome post! But what causes an error to rise when I try to use an .mjs file inside of a js file ? Are they limits to interoperability of module formats ?

[Ahmed Elhady](https://hashnode.com/@th3h4dyy)

[Dec 26, 2022](https://hashnode.com/posts/what-really-happens-when-we-require-a-module-in-nodejs/63a8f90a1ba9a9c0dc2a6927/comment/63a924878de4e0eeae64f01d#reply-63a9800db1011ed9ec6d44cb)

Sometimes these problems rise because of some differences between `CJS` and `ESM` when it comes to use `.mjs` -- see the difference from here: [nodejs.org/docs/latest/api/esm.html](https://nodejs.org/docs/latest/api/esm.html#esm_differences_between_es_modules_and_commonjs)

People still shy from the `.mjs` and they use babel or typescript to get interoperability between the two types of modules.

I think it's the future, but, for now, they use the `.js` and allow for `ESM` in their code base in whatever method is available.
