# How to reload modified module

**URL:** <https://discourse.nodered.org/t/how-to-reload-modified-module/55878>\
**Category:** Developing Nodes\
**Created:** [30 December 2021 09:06 UTC](https://discourse.nodered.org/t/how-to-reload-modified-module/55878 "2021-12-30T09:06:47Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![borpin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/borpin/32/1765_2.png) [@borpin](https://discourse.nodered.org/u/borpin)\
**Post date:** [30 December 2021 09:06 UTC](https://discourse.nodered.org/t/how-to-reload-modified-module/55878/1 "2021-12-30T09:06:47Z")

</div>

What is the quickest way to force Node-RED to reload a module that has been modified on disk?

Previously I have found I needed to restart Node-RED and refresh the browser, but I am wondering if there is an easier/quicker way to force the reload of a specific module.

Are there any good tutorials on developing modules? Currently using a Remote VS Code setup to edit the files on disk, but I have no idea on how to run a debugger or how best to deploy (as above). I'm OK with using Git to manage changes.

---

<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:** [30 December 2021 15:12 UTC](https://discourse.nodered.org/t/how-to-reload-modified-module/55878/2 "2021-12-30T15:12:14Z")

</div>

I'm not aware of a way to reload a single module - comes down to the way that node.js handles `require` I think.

What I do is to run my development version under PM2 with watches in place so that changed files that require a restart of node-red do so automatically.

I also develop on my main Windows PC, deploy to GitHub (publish to [npmjs.org](http://npmjs.org) if a public release) and update other platforms from [npmjs.org](http://npmjs.org) or GitHub as appropriate. That way, I only need to do an `npm install c:\path\to\local\code`, whenever I save a change, node-red simply restarts.

This also makes debugging easier if/when you need to run it. I rarely run it unless I have some really tricky problem since you have to debug the whole of Node-RED which is quite complex. I generally rely on copius console.xxx and node-red log statements. I also have a custom flow on my "live" home automation server that a custom log setting uses - via MQTT, it outputs trace-level details just for my nodes and debug level for everything else - to a web page via uibuilder.

Running Node-RED in debug mode has been covered in the forum before. When done locally, you just need to start node-red passing the `--inspect` flag to node.js and have a suitable breakpoint somewhere early on - I usually put it at the end of settings.js.

---

<div class="post-metadata">

**Author:** ![hardillb](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/hardillb/32/12373_2.png) [@hardillb](https://discourse.nodered.org/u/hardillb)\
**Post date:** [30 December 2021 15:17 UTC](https://discourse.nodered.org/t/how-to-reload-modified-module/55878/3 "2021-12-30T15:17:23Z")

</div>

> **[Debugging Node-RED nodes with Visual Code](https://www.hardill.me.uk/wordpress/2021/12/18/debugging-node-red-nodes-with-visual-code/)**
>
> A recent Stack Overflow post had me looking at how to run Node-RED using Visual Code to debug custom nodes. Since I’d not tried Visual Code before (I tend to use Sublime Text 4 as my day to d…

Might help

But you will need to restart as nodejs offers no easy to reload modules

---

<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:** [28 February 2022 15:18 UTC](https://discourse.nodered.org/t/how-to-reload-modified-module/55878/4 "2022-02-28T15:18:08Z")

</div>

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