# Unable to start node-red after attempted upgrade - Cannot find module 'node:dns'

**URL:** <https://discourse.nodered.org/t/unable-to-start-node-red-after-attempted-upgrade-cannot-find-module-node-dns/85277>\
**Category:** General\
**Created:** [7 February 2024 01:47 UTC](https://discourse.nodered.org/t/unable-to-start-node-red-after-attempted-upgrade-cannot-find-module-node-dns/85277 "2024-02-07T01:47:51Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![Alekeep](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/alekeep/32/88058_2.png) [@Alekeep](https://discourse.nodered.org/u/Alekeep)\
**Post date:** [7 February 2024 01:47 UTC](https://discourse.nodered.org/t/unable-to-start-node-red-after-attempted-upgrade-cannot-find-module-node-dns/85277/1 "2024-02-07T01:47:52Z")

</div>

Starting a new project so figured it would be good to start with the latest release of node-red. Per the [nodered.org](http://nodered.org) site, I ran this from the Windows command prompt thinking it would do the trick:  
**npm install -g --unsafe-perm node-red**  
After allowing this to run, attempted to restart node-red and, unfortunately, that didn't go as expected. Nothing I have found thus far have allowed me to correct the problem. Any guidance is appreciated.

```auto
C:\Users\Ray>node-red
node:internal/modules/cjs/loader:927
  throw err;
  ^

Error: Cannot find module 'node:dns'
Require stack:
- C:\Users\Ray\AppData\Roaming\npm\node_modules\node-red\lib\red.js
- C:\Users\Ray\AppData\Roaming\npm\node_modules\node-red\red.js
    at Function.Module._resolveFilename (node:internal/modules/cjs/loader:924:15)
    at Function.Module._load (node:internal/modules/cjs/loader:769:27)
    at Module.require (node:internal/modules/cjs/loader:996:19)
    at require (node:internal/modules/cjs/helpers:92:18)
    at Object.<anonymous> (C:\Users\Ray\AppData\Roaming\npm\node_modules\node-red\lib\red.js:30:17)
    at Module._compile (node:internal/modules/cjs/loader:1092:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1121:10)
    at Module.load (node:internal/modules/cjs/loader:972:32)
    at Function.Module._load (node:internal/modules/cjs/loader:813:14)
    at Module.require (node:internal/modules/cjs/loader:996:19) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [
    'C:\\Users\\Ray\\AppData\\Roaming\\npm\\node_modules\\node-red\\lib\\red.js',
    'C:\\Users\\Ray\\AppData\\Roaming\\npm\\node_modules\\node-red\\red.js'
  ]
}

```

---

<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:** [7 February 2024 09:40 UTC](https://discourse.nodered.org/t/unable-to-start-node-red-after-attempted-upgrade-cannot-find-module-node-dns/85277/2 "2024-02-07T09:40:34Z")

</div>

What version of Node-RED and node.js do you have installed? I think that the node.js `node:dns` module is only available from node.js v18. It was called `dns` before.

---

<div class="post-metadata">

**Author:** ![Alekeep](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/alekeep/32/88058_2.png) [@Alekeep](https://discourse.nodered.org/u/Alekeep)\
**Post date:** [7 February 2024 13:18 UTC](https://discourse.nodered.org/t/unable-to-start-node-red-after-attempted-upgrade-cannot-find-module-node-dns/85277/3 "2024-02-07T13:18:39Z")

</div>

The blog entry for rhe release of v3.1 led to the get started page where with the command shown above to upgrade. No version is referenced so assume it would pull the latest at 3.1.x.  
[https://nodered.org/docs/getting-started/local](https://nodered.org/docs/getting-started/local)

It is mentioned on that page, as you referenced in your reply, a compatable version of jode.js. I will check/upgrade and report back.

Thank you!

---

<div class="post-metadata">

**Author:** ![Alekeep](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/alekeep/32/88058_2.png) [@Alekeep](https://discourse.nodered.org/u/Alekeep)\
**Post date:** [7 February 2024 14:18 UTC](https://discourse.nodered.org/t/unable-to-start-node-red-after-attempted-upgrade-cannot-find-module-node-dns/85277/4 "2024-02-07T14:18:18Z")

</div>

Node.js update from 15.14.0 to 21.6.0 and an npm rebuild did the trick!  
Thank you very much!

---

<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:** [7 February 2024 14:34 UTC](https://discourse.nodered.org/t/unable-to-start-node-red-after-attempted-upgrade-cannot-find-module-node-dns/85277/5 "2024-02-07T14:34:29Z")

</div>

@knolleary , @Steve-Mcl - is this a bug in the latest release of Node-RED? As Node-RED v3 is meant to be baselined against Node.js v14, I think it should be using the `dns` module and not `node:dns`?

---

<div class="post-metadata">

**Author:** ![knolleary](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/knolleary/32/3_2.png) [@knolleary](https://discourse.nodered.org/u/knolleary)\
**Post date:** [7 February 2024 14:36 UTC](https://discourse.nodered.org/t/unable-to-start-node-red-after-attempted-upgrade-cannot-find-module-node-dns/85277/6 "2024-02-07T14:36:17Z")

</div>

The use of `node:dns` is guarded behind a check of the node.js version... need to figure out how/why that isn't doing what is expected.

---

<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:** [7 February 2024 14:38 UTC](https://discourse.nodered.org/t/unable-to-start-node-red-after-attempted-upgrade-cannot-find-module-node-dns/85277/7 "2024-02-07T14:38:16Z")

</div>

I thought you could still use just `dns`? Though, to be honest, I've not checked that module. I've been more focused on the `fs` module recently.

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [7 February 2024 14:43 UTC](https://discourse.nodered.org/t/unable-to-start-node-red-after-attempted-upgrade-cannot-find-module-node-dns/85277/8 "2024-02-07T14:43:37Z")

</div>

Looking at the node docs, `node:dns` first shows up in v16.

Therefore the guard is not adequate to cover odd versions (pretty sure the docs do state dont use odd numbered versions of node 😛 )

In short, [the guard](https://github.com/node-red/node-red/blob/918943816f44c743148baf8a5b5f081fdff4814d/packages/node_modules/node-red/lib/red.js#L29) should probably check for \>= 16 (not just \> 14)

---

<div class="post-metadata">

**Author:** ![knolleary](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/knolleary/32/3_2.png) [@knolleary](https://discourse.nodered.org/u/knolleary)\
**Post date:** [7 February 2024 14:44 UTC](https://discourse.nodered.org/t/unable-to-start-node-red-after-attempted-upgrade-cannot-find-module-node-dns/85277/9 "2024-02-07T14:44:54Z")

</div>

In this instance,we want to call a function of the DNS module that was introduced after Node 14 - which is why it makes the check. That said, you are quite right that it doesn't need to use the `node:` prefix either way.

I have another bug to fix before anyone sees it in the wild and will be doing 3.1.5 release in the next 24 hours. I'll update this require statement as well.

---

<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:** [7 February 2024 14:49 UTC](https://discourse.nodered.org/t/unable-to-start-node-red-after-attempted-upgrade-cannot-find-module-node-dns/85277/10 "2024-02-07T14:49:49Z")

</div>

> [@knolleary](#):
>
> In this instance,we want to call a function of the DNS module that was introduced after Node 14

Dare I ask about v4? 🙂

---

<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:** [21 February 2024 14:50 UTC](https://discourse.nodered.org/t/unable-to-start-node-red-after-attempted-upgrade-cannot-find-module-node-dns/85277/11 "2024-02-21T14:50:19Z")

</div>

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