Read COM1 Port Data

I am having trouble getting Node-Red to read data from com1
I have Node-Red setup on docker because I could not get it to work on my windows system with Node.JS
Node-Red
1.2.7
node-red-contrib-modbus
5.13.3
I am trying to create a basic Modbus to MQTT translator.
When I have a Modbus Read node linked to a debug node nothing happens because Modbus Read node says reconnecting all the time, not active? Is this because node red can read from the host machines com1 port?
How do I allow nod red to access com1?

I have a Modbus app on desktop that can read the device on com1.

Setting up on windows is quite simple and will reduce the complexity. If you dont need docker (or you are not up to speed on docker), its best to avoid it (IMO)

The official instructions have never failed to work for me on windows...

https://nodered.org/docs/getting-started/windows

I'm happy to setup node.js and yes it was simple , But I had a error and the server would not start.

Is there a way to just reinstall node-red under nod.js?

27 Jan 21:46:36 - [info] Starting flows
27 Jan 21:46:36 - [info] Started flows
27 Jan 21:46:37 - [red] Uncaught Exception:
27 Jan 21:46:37 - Error: Could not locate the bindings file. Tried:
→ C:\Users\Admin.node-red\node_modules\modbus-serial\node_modules@serialport\bindings\build\bindings.node
→ C:\Users\Admin.node-red\node_modules\modbus-serial\node_modules@serialport\bindings\build\Debug\bindings.node
→ C:\Users\Admin.node-red\node_modules\modbus-serial\node_modules@serialport\bindings\build\Release\bindings.node
→ C:\Users\Admin.node-red\node_modules\modbus-serial\node_modules@serialport\bindings\out\Debug\bindings.node
→ C:\Users\Admin.node-red\node_modules\modbus-serial\node_modules@serialport\bindings\Debug\bindings.node
→ C:\Users\Admin.node-red\node_modules\modbus-serial\node_modules@serialport\bindings\out\Release\bindings.node
→ C:\Users\Admin.node-red\node_modules\modbus-serial\node_modules@serialport\bindings\Release\bindings.node
→ C:\Users\Admin.node-red\node_modules\modbus-serial\node_modules@serialport\bindings\build\default\bindings.node
→ C:\Users\Admin.node-red\node_modules\modbus-serial\node_modules@serialport\bindings\compiled\15.6.0\win32\x64\bindings.node
→ C:\Users\Admin.node-red\node_modules\modbus-serial\node_modules@serialport\bindings\addon-build\release\install-root\bindings.node
→ C:\Users\Admin.node-red\node_modules\modbus-serial\node_modules@serialport\bindings\addon-build\debug\install-root\bindings.node
→ C:\Users\Admin.node-red\node_modules\modbus-serial\node_modules@serialport\bindings\addon-build\default\install-root\bindings.node
→ C:\Users\Admin.node-red\node_modules\modbus-serial\node_modules@serialport\bindings\lib\binding\node-v88-win32-x64\bindings.node
at bindings (C:\Users\Admin.node-red\node_modules\bindings\bindings.js:126:9)
at Object. (C:\Users\Admin.node-red\node_modules\modbus-serial\node_modules@serialport\bindings\lib\win32.js:1:36)
at Module._compile (node:internal/modules/cjs/loader:1108:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1137:10)
at Module.load (node:internal/modules/cjs/loader:973:32)
at Function.Module._load (node:internal/modules/cjs/loader:813:14)
at Module.require (node:internal/modules/cjs/loader:997:19)
at require (node:internal/modules/cjs/helpers:92:18)
at Object. (C:\Users\Admin.node-red\node_modules\modbus-serial\node_modules@serialport\bindings\lib\index.js:6:22)
at Module._compile (node:internal/modules/cjs/loader:1108:14)

C:\Users\Admin>

This is the errors I am getting when I install the Modbus package

C:\Users\Admin>npm install -g node-red-contrib-modbus
npm WARN deprecated debug@4.1.1: Debug versions >=3.2.0 <3.2.7 || >=4 <4.3.1 have a low-severity ReDos regression when used in a Node.js environment. It is recommended you upgrade to 3.2.7 or 4.3.1. (https://github.com/visionmedia/debug/issues/797)

> @serialport/bindings@8.0.8 install C:\Users\Admin\AppData\Roaming\npm\node_modules\node-red-contrib-modbus\node_modules\modbus-serial\node_modules\@serialport\bindings
> prebuild-install --tag-prefix @serialport/bindings@ || node-gyp rebuild

prebuild-install WARN install No prebuilt binaries found (target=15.6.0 runtime=node arch=x64 libc= platform=win32)

C:\Users\Admin\AppData\Roaming\npm\node_modules\node-red-contrib-modbus\node_modules\modbus-serial\node_modules\@serialport\bindings>if not defined npm_config_node_gyp (node "C:\Users\Admin\AppData\Roaming\npm\node_modules\npm\node_modules\npm-lifecycle\node-gyp-bin\\..\..\node_modules\node-gyp\bin\node-gyp.js" rebuild )  else (node "C:\Users\Admin\AppData\Roaming\npm\node_modules\npm\node_modules\node-gyp\bin\node-gyp.js" rebuild )
gyp: C:\Users\Admin\AppData\Local\node-gyp\Cache\15.6.0\common.gypi not found (cwd: C:\Users\Admin\AppData\Roaming\npm\node_modules\node-red-contrib-modbus\node_modules\modbus-serial\node_modules\@serialport\bindings) while reading includes of binding.gyp while trying to load binding.gyp
gyp ERR! configure error
gyp ERR! stack Error: `gyp` failed with exit code: 1
gyp ERR! stack     at ChildProcess.onCpExit (C:\Users\Admin\AppData\Roaming\npm\node_modules\npm\node_modules\node-gyp\lib\configure.js:351:16)
gyp ERR! stack     at ChildProcess.emit (node:events:379:20)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (node:internal/child_process:285:12)
gyp ERR! System Windows_NT 10.0.19042
gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "C:\\Users\\Admin\\AppData\\Roaming\\npm\\node_modules\\npm\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild"
gyp ERR! cwd C:\Users\Admin\AppData\Roaming\npm\node_modules\node-red-contrib-modbus\node_modules\modbus-serial\node_modules\@serialport\bindings
gyp ERR! node -v v15.6.0
gyp ERR! node-gyp -v v5.1.0
gyp ERR! not ok
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! @serialport/bindings@8.0.8 install: `prebuild-install --tag-prefix @serialport/bindings@ || node-gyp rebuild`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the @serialport/bindings@8.0.8 install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\Admin\AppData\Roaming\npm-cache\_logs\2021-01-27T09_03_38_509Z-debug.log

C:\Users\Admin>

Do you have build tools installed?

Also, it looks like you have installed NODE V15 - this is not recommended. V14 works fine.

No but I have just added the tools now, Not sure how to use them?

I notice that the problem happens when I install Modbus package, When I delete the Node-Red folder in the user directory, Node red will restart again,


-----------------------------------------------------------
2021-01-27T09:23:47.622Z Install : node-red-contrib-modbus 5.13.3

2021-01-27T09:23:47.940Z npm.cmd install --no-audit --no-update-notifier --no-fund --save --save-prefix=~ --production node-red-contrib-modbus@5.13.3
2021-01-27T09:23:49.342Z [err] npm WARN deprecated debug@4.1.1: Debug versions >=3.2.0 <3.2.7 || >=4 <4.3.1 have a low-severity ReDos regression when used in a Node.js environment. It is recommended you upgrade to 3.2.7 or 4.3.1. (https://github.com/visionmedia/debug/issues/797)
2021-01-27T09:23:54.738Z [out] 
2021-01-27T09:23:54.738Z [out] > @serialport/bindings@8.0.8 install C:\Users\Admin\.node-red\node_modules\modbus-serial\node_modules\@serialport\bindings
2021-01-27T09:23:54.738Z [out] > prebuild-install --tag-prefix @serialport/bindings@ || node-gyp rebuild
2021-01-27T09:23:54.738Z [out] 
2021-01-27T09:23:55.345Z [err] prebuild-install WARN 
2021-01-27T09:23:55.345Z [err] install No prebuilt binaries found (target=15.6.0 runtime=node arch=x64 libc= platform=win32)
2021-01-27T09:23:55.354Z [out] 
2021-01-27T09:23:55.354Z [out] C:\Users\Admin\.node-red\node_modules\modbus-serial\node_modules\@serialport\bindings>if not defined npm_config_node_gyp (node "C:\Users\Admin\AppData\Roaming\npm\node_modules\npm\node_modules\npm-lifecycle\node-gyp-bin\\..\..\node_modules\node-gyp\bin\node-gyp.js" rebuild )  else (node "C:\Users\Admin\AppData\Roaming\npm\node_modules\npm\node_modules\node-gyp\bin\node-gyp.js" rebuild ) 
2021-01-27T09:23:56.367Z [err] gyp: C:\Users\Admin\AppData\Local\node-gyp\Cache\15.6.0\common.gypi not found (cwd: C:\Users\Admin\.node-red\node_modules\modbus-serial\node_modules\@serialport\bindings) while reading includes of binding.gyp while trying to load binding.gyp
2021-01-27T09:23:56.371Z [err] gyp
2021-01-27T09:23:56.371Z [err]  ERR! configure error 
2021-01-27T09:23:56.372Z [err] gyp 
2021-01-27T09:23:56.372Z [err] ERR! stack Error: `gyp` failed with exit code: 1
2021-01-27T09:23:56.372Z [err] gyp ERR! stack     at ChildProcess.onCpExit (C:\Users\Admin\AppData\Roaming\npm\node_modules\npm\node_modules\node-gyp\lib\configure.js:351:16)
2021-01-27T09:23:56.372Z [err] gyp
2021-01-27T09:23:56.372Z [err]  ERR! stack     at ChildProcess.emit (node:events:379:20)
2021-01-27T09:23:56.372Z [err] gyp ERR! stack     at Process.ChildProcess._handle.onexit (node:internal/child_process:285:12)
2021-01-27T09:23:56.372Z [err] gyp ERR!
2021-01-27T09:23:56.372Z [err]  System Windows_NT 10.0.19042
2021-01-27T09:23:56.372Z [err] gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "C:\\Users\\Admin\\AppData\\Roaming\\npm\\node_modules\\npm\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild"
2021-01-27T09:23:56.372Z [err] gyp ERR! cwd C:\Users\Admin\.node-red\node_modules\modbus-serial\node_modules\@serialport\bindings
2021-01-27T09:23:56.372Z [err] gyp ERR! node -v
2021-01-27T09:23:56.372Z [err]  v15.6.0
2021-01-27T09:23:56.372Z [err] gyp ERR! node-gyp -v v5.1.0
2021-01-27T09:23:56.372Z [err] gyp 
2021-01-27T09:23:56.372Z [err] ERR! not ok 
2021-01-27T09:23:56.468Z [err] npm ERR! code ELIFECYCLE
2021-01-27T09:23:56.468Z [err] npm ERR! errno 1
2021-01-27T09:23:56.479Z [err] npm ERR! @serialport/bindings@8.0.8 install: `prebuild-install --tag-prefix @serialport/bindings@ || node-gyp rebuild`
2021-01-27T09:23:56.479Z [err] npm ERR! Exit status 1
2021-01-27T09:23:56.479Z [err] npm ERR! 
2021-01-27T09:23:56.479Z [err] npm ERR! Failed at the @serialport/bindings@8.0.8 install script.
2021-01-27T09:23:56.479Z [err] npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
2021-01-27T09:23:56.497Z [err] 
2021-01-27T09:23:56.497Z [err] npm
2021-01-27T09:23:56.497Z [err]  ERR! A complete log of this run can be found in:
2021-01-27T09:23:56.497Z [err] npm ERR!     C:\Users\Admin\AppData\Roaming\npm-cache\_logs\2021-01-27T09_23_56_481Z-debug.log
2021-01-27T09:23:56.511Z rc=1```

I would strongly recommend starting over.

  1. install node V14
  2. install build tools
  3. install node-red
  4. install modbus node

Ok will try that, How do I install a specific version

this was how I reinstalled Node-Red last time

npm install -g --unsafe-perm node-red

Of Nodejs? You download the V14 instead of V15.

For npm, you would add @x.y.z e.g. npm install mynode@1.2.3

That was it , All working now, and I can see the com port,
Thank You

1 Like

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