# Modbus TCP and process.env.NODE\_RED\_HOME

**URL:** <https://discourse.nodered.org/t/modbus-tcp-and-process-env-node-red-home/9643>\
**Category:** General\
**Created:** [1 April 2019 03:12 UTC](https://discourse.nodered.org/t/modbus-tcp-and-process-env-node-red-home/9643 "2019-04-01T03:12:25Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![CaptClaude](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/captclaude/32/2125_2.png) [@CaptClaude](https://discourse.nodered.org/u/CaptClaude)\
**Post date:** [1 April 2019 03:12 UTC](https://discourse.nodered.org/t/modbus-tcp-and-process-env-node-red-home/9643/1 "2019-04-01T03:12:25Z")

</div>

First: Running Windows 10 and a freshly installed NR with node.js 10.15.3.

I am trying to communicate with a Modbus TCP slave and am having some success with the biancode and Argonne-National-Labs contrib nodes. However the [altamira](https://github.com/altamira)/ **[node-red-contrib-modbustcp-no-pooling](https://github.com/altamira/node-red-contrib-modbustcp-no-pooling)**  
seems not to install, although the failure is only apparent when I re-start NR and get the error

> 29 Mar 16:48:02 - [warn] [node-red-contrib-modbustcp-no-pooling/modbus tcp] Error: Cannot find module 'C:\Users\mizejc\AppData\Roaming\npm\node\_modules\node-red/red/red' (line:46)

The node installs **modbustcp.js** which contains the lines:

> module.exports = function (RED) {  
> var RED = require(process.env.NODE\_RED\_HOME+"/red/red");

which seems to be the source of the problem because of the "/red/red" path substring which is not a Windows thing. But I don't know enough about node.js to know whether that's really it or not.

Any suggestions?

Thanks.

I've opened an issue but they haven't done anything in 3 years so I don't have a very high expectation of a response.

If anyone wants to recommend which of the Modbus TCP "libraries" (is that the right word?) is the best, I'm open for suggestions.

---

<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:** [1 April 2019 07:21 UTC](https://discourse.nodered.org/t/modbus-tcp-and-process-env-node-red-home/9643/2 "2019-04-01T07:21:04Z")

</div>

Hi @CaptClaude

it looks like that node is still using a way of accessing the Node-RED runtime that has been long deprecated and should have been updated years ago.

The 0.20 release of Node-RED changed the internal layout of the code, so the assumptions that node made about how to access the core of the runtime no longer hold true.

I see you've already raised an issue on the node - that's the right first place to start in resolving this.

---

<div class="post-metadata">

**Author:** ![CaptClaude](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/captclaude/32/2125_2.png) [@CaptClaude](https://discourse.nodered.org/u/CaptClaude)\
**Post date:** [1 April 2019 21:43 UTC](https://discourse.nodered.org/t/modbus-tcp-and-process-env-node-red-home/9643/3 "2019-04-01T21:43:01Z")

</div>

Both node-red-contrib-modbustcp and node-red-contrib-modbustcp **-no-pooling** bring with them files names **modbustcp.js** and both files have identical headers, but they are **very** different.

Fortunately for me there is a more consistently maintained Modbus TCP library (is that the right word?) that I can use: Klaus Landsdorf's **[node-red-contrib-modbus](https://github.com/biancode/node-red-contrib-modbus)** with which I am slowly coming to grips.

Thanks.
