# Using type module project for Node-RED

**URL:** <https://discourse.nodered.org/t/using-type-module-project-for-node-red/95350>\
**Category:** Developing Nodes\
**Created:** [12 February 2025 14:26 UTC](https://discourse.nodered.org/t/using-type-module-project-for-node-red/95350 "2025-02-12T14:26:00Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![eryanph](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/eryanph/32/98784_2.png) [@eryanph](https://discourse.nodered.org/u/eryanph)\
**Post date:** [12 February 2025 14:26 UTC](https://discourse.nodered.org/t/using-type-module-project-for-node-red/95350/1 "2025-02-12T14:26:01Z")

</div>

Hi, is there a way to make a type module project work with Node-RED? I tried it and I will get the following error once I start Node-RED:

```auto
Error [ERR_REQUIRE_ESM]: require() of ES Module /Users/hallownest/Repositories/node-red-project/src/my-node.js from /Users/hallownest/.npm-packages/lib/node_modules/node-red/node_modules/@node-red/registry/lib/loader.js not supported.

```

It's also worth noting that one of the dependencies I use only supports ESM, so I am pressed to be ESM as well, unless I want to do _hacky_ changes to accommodate it (dynamic imports).

---

<div class="post-metadata">

**Author:** ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)\
**Post date:** [12 February 2025 14:51 UTC](https://discourse.nodered.org/t/using-type-module-project-for-node-red/95350/2 "2025-02-12T14:51:49Z")

</div>

I do think that someone posted an example of using ES modules with Node-RED some time last year. It appeared to be possible. It is certainly possible for the Editor and I've already started to convert my main package. Not so sure about converting the runtime but I remember that the example showed that.

As for loading ES modules as dependencies, as long as you are using newer versions of node.js (as you should now be), you _can_ load ES module dependencies. But obviously, if your own runtime code is not an ES module then you have to load the ES Modules using the async version of `import()`. You cannot `require` them.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [13 April 2025 14:52 UTC](https://discourse.nodered.org/t/using-type-module-project-for-node-red/95350/3 "2025-04-13T14:52:49Z")

</div>

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.
