Trouble with contrib-modbus module

I am having trouble with contrib-modbus 4.1.3 communicating with a PLC. Version 3.6.1 works fine in a similar setup at a different location. Following the info I try ti install a later version but get the following error even logged in as administrator. Are there any suggestions on loading a previous version, or am I missing something else? v10.16.3 && 6.9.0

C:\Windows\system32>npm install -g node-red-contrib-modbus@3.6.1

> serialport@6.1.1 install C:\Users\P51QHMIPC00\AppData\Roaming\npm\node_modules
\node-red-contrib-modbus\node_modules\serialport
> prebuild-install || node-gyp rebuild

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

C:\Users\P51QHMIPC00\AppData\Roaming\npm\node_modules\node-red-contrib-modbus\no
de_modules\serialport>if not defined npm_config_node_gyp (node "C:\Program Files
\nodejs\node_modules\npm\node_modules\npm-lifecycle\node-gyp-bin\\..\..\node_mod
ules\node-gyp\bin\node-gyp.js" rebuild )  else (node "C:\Program Files\nodejs\no
de_modules\npm\node_modules\node-gyp\bin\node-gyp.js" rebuild )
gyp ERR! configure error
gyp ERR! stack Error: Can't find Python executable "python", you can set the PYT
HON env variable.
gyp ERR! stack     at PythonFinder.failNoPython (C:\Program Files\nodejs\node_mo
dules\npm\node_modules\node-gyp\lib\configure.js:484:19)
gyp ERR! stack     at PythonFinder.<anonymous> (C:\Program Files\nodejs\node_mod
ules\npm\node_modules\node-gyp\lib\configure.js:509:16)
gyp ERR! stack     at C:\Program Files\nodejs\node_modules\npm\node_modules\grac
eful-fs\polyfills.js:282:31
gyp ERR! stack     at FSReqWrap.oncomplete (fs.js:153:21)
gyp ERR! System Windows_NT 6.1.7601
gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodej
s\\node_modules\\npm\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild"
gyp ERR! cwd C:\Users\P51QHMIPC00\AppData\Roaming\npm\node_modules\node-red-cont
rib-modbus\node_modules\serialport
gyp ERR! node -v v10.16.3
gyp ERR! node-gyp -v v3.8.0
gyp ERR! not ok
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! serialport@6.1.1 install: `prebuild-install || node-gyp rebuild`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the serialport@6.1.1 install script.
npm ERR! This is probably not a problem with npm. There is likely additional log
ging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\P51QHMIPC00\AppData\Roaming\npm-cache\_logs\2019-11-07T20_
58_40_188Z-debug.log

C:\Windows\system32>

Seems like the serialport package is trying to build its native code, but it fails because your build environment isn't properly set up. Python is missing (required for node-gyp to work).

There is a setup guide for Windows on the node-gyp Github page:

The clue is there ^

You actually need windows build tools then try installing that node again

I don't use Windows, but should you be installing it globally?

That's a good point, too. You should install nodes locally into your Node-RED workspace (by default .node-red in your user profile).

I attempted to install the Build Tools using:

npm install --global --production --add-python-to-path windows-build-tools

at CMD running as administrator. A result was given at the end that Python Installed Successfully, however after trying to run

npm install node-red-contrib-modbus@3.6.1

I recieved:

Microsoft Windows [Version 6.1.7601]
Copyright (c) 2009 Microsoft Corporation. All rights reserved.

C:\Windows\system32>npm install node-red-contrib-modbus@3.6.1

serialport@6.1.1 install C:\Windows\system32\node_modules\serialport
prebuild-install || node-gyp rebuild

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

C:\Windows\system32\node_modules\serialport>if not defined npm_config_node_gyp (
node "C:\Program Files\nodejs\node_modules\npm\node_modules\npm-lifecycle\node-g
yp-bin\....\node_modules\node-gyp\bin\node-gyp.js" rebuild ) else (node "C:\P
rogram Files\nodejs\node_modules\npm\node_modules\node-gyp\bin\node-gyp.js" rebu
ild )
gyp ERR! configure error
gyp ERR! stack Error: Can't find Python executable "python", you can set the PYT
HON env variable.
gyp ERR! stack at PythonFinder.failNoPython (C:\Program Files\nodejs\node_mo
dules\npm\node_modules\node-gyp\lib\configure.js:484:19)
gyp ERR! stack at PythonFinder. (C:\Program Files\nodejs\node_mod
ules\npm\node_modules\node-gyp\lib\configure.js:509:16)
gyp ERR! stack at C:\Program Files\nodejs\node_modules\npm\node_modules\grac
eful-fs\polyfills.js:282:31
gyp ERR! stack at FSReqWrap.oncomplete (fs.js:153:21)
gyp ERR! System Windows_NT 6.1.7601
gyp ERR! command "C:\Program Files\nodejs\node.exe" "C:\Program Files\nodej
s\node_modules\npm\node_modules\node-gyp\bin\node-gyp.js" "rebuild"
gyp ERR! cwd C:\Windows\system32\node_modules\serialport
gyp ERR! node -v v10.16.3
gyp ERR! node-gyp -v v3.8.0
gyp ERR! not ok
npm WARN enoent ENOENT: no such file or directory, open 'C:\Windows\system32\pac
kage.json'
npm WARN system32 No description
npm WARN system32 No repository field.
npm WARN system32 No README data
npm WARN system32 No license field.

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! serialport@6.1.1 install: prebuild-install || node-gyp rebuild
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the serialport@6.1.1 install script.
npm ERR! This is probably not a problem with npm. There is likely additional log
ging output above.

npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\P51QHMIPC00\AppData\Roaming\npm-cache_logs\2019-11-08T14_
00_05_634Z-debug.log

C:\Windows\system32>

Did I install the build Tool incorrectly?

Did you reboot or logout after you installed the build tools? Maybe python isn't in your path yet.

Does it find python if you execute it in cmd shell?

I think there was also an option for your .npmrc to set the path to the python executable by executing:
npm config set python /path/to/executable/python

That's what I did at work on my Windows PC. I can't check it right now as I only have Linux machines at home.

You are trying to install it from your Windows system folder, you have to do it from your node red folder, or use the node red palette manager in the editor.

OK, Python apparently is installed, but maybe not in the correct place?

I will try to install from the Node-Red folder now. Thanks

Same error, Cant not find Python Executable.

Put path to python27 in your environmental variables.

OK, I added Python to the environment variables. I now have a new result, possibly on the right track?

Microsoft Windows [Version 6.1.7601]
Copyright (c) 2009 Microsoft Corporation. All rights reserved.

C:\Users\P51QHMIPC00.node-red>npm install node-red-contrib-modbus@3.6.1

serialport@6.1.1 install C:\Users\P51QHMIPC00.node-red\node_modules\serialpor
t
prebuild-install || node-gyp rebuild

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

C:\Users\P51QHMIPC00.node-red\node_modules\serialport>if not defined npm_config
_node_gyp (node "C:\Program Files\nodejs\node_modules\npm\node_modules\npm-lifec
ycle\node-gyp-bin\....\node_modules\node-gyp\bin\node-gyp.js" rebuild ) else
(node "C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\bin\node-g
yp.js" rebuild )
Building the projects in this solution one at a time. To enable parallel build,
please add the "/m" switch.
serialport.cpp
serialport_win.cpp
c:\users\p51qhmipc00.node-red\node_modules\serialport\src\serialport.cpp(41):
warning C4996: 'v8::String::Utf8Value::Utf8Value': was declared deprecated [C:
Users\P51QHMIPC00.node-red\node_modules\serialport\build\serialport.vcxproj]
c:\users\p51qhmipc00.node-gyp\10.16.3\include\node\v8.h(2891): note: see dec
laration of 'v8::String::Utf8Value::Utf8Value'
c:\users\p51qhmipc00.node-red\node_modules\serialport\src\serialport.cpp(48):
warning C4996: 'v8::Value::ToObject': was declared deprecated [C:\Users\P51QHMI
PC00.node-red\node_modules\serialport\build\serialport.vcxproj]
c:\users\p51qhmipc00.node-gyp\10.16.3\include\node\v8.h(10046): note: see de
claration of 'v8::Value::ToObject'
c:\users\p51qhmipc00.node-red\node_modules\serialport\src\serialport.cpp(95):
warning C4996: 'Nan::Callback::Call': was declared deprecated [C:\Users\P51QHMI
PC00.node-red\node_modules\serialport\build\serialport.vcxproj]
c:\users\p51qhmipc00.node-red\node_modules\nan\nan.h(1740): note: see declar
ation of 'Nan::Callback::Call'
c:\users\p51qhmipc00.node-red\node_modules\serialport\src\serialport.cpp(113):
warning C4996: 'v8::Value::ToObject': was declared deprecated [C:\Users\P51QHM
IPC00.node-red\node_modules\serialport\build\serialport.vcxproj]
c:\users\p51qhmipc00.node-gyp\10.16.3\include\node\v8.h(10046): note: see de
claration of 'v8::Value::ToObject'
c:\users\p51qhmipc00.node-red\node_modules\serialport\src\serialport.cpp(150):
warning C4996: 'Nan::Callback::Call': was declared deprecated [C:\Users\P51QHM
IPC00.node-red\node_modules\serialport\build\serialport.vcxproj]
c:\users\p51qhmipc00.node-red\node_modules\nan\nan.h(1740): note: see declar
ation of 'Nan::Callback::Call'
c:\users\p51qhmipc00.node-red\node_modules\serialport\src\serialport.cpp(188):
warning C4996: 'Nan::Callback::Call': was declared deprecated [C:\Users\P51QHM
IPC00.node-red\node_modules\serialport\build\serialport.vcxproj]
c:\users\p51qhmipc00.node-red\node_modules\nan\nan.h(1740): note: see declar
ation of 'Nan::Callback::Call'
c:\users\p51qhmipc00.node-red\node_modules\serialport\src\serialport.cpp(231):
warning C4996: 'Nan::Callback::Call': was declared deprecated [C:\Users\P51QHM
IPC00.node-red\node_modules\serialport\build\serialport.vcxproj]
c:\users\p51qhmipc00.node-red\node_modules\nan\nan.h(1740): note: see declar
ation of 'Nan::Callback::Call'
c:\users\p51qhmipc00.node-red\node_modules\serialport\src\serialport.cpp(250):
warning C4996: 'v8::Value::ToObject': was declared deprecated [C:\Users\P51QHM
IPC00.node-red\node_modules\serialport\build\serialport.vcxproj]
c:\users\p51qhmipc00.node-gyp\10.16.3\include\node\v8.h(10046): note: see de
claration of 'v8::Value::ToObject'
c:\users\p51qhmipc00.node-red\node_modules\serialport\src\serialport.cpp(285):
warning C4996: 'Nan::Callback::Call': was declared deprecated [C:\Users\P51QHM
IPC00.node-red\node_modules\serialport\build\serialport.vcxproj]
c:\users\p51qhmipc00.node-red\node_modules\nan\nan.h(1740): note: see declar
ation of 'Nan::Callback::Call'
c:\users\p51qhmipc00.node-red\node_modules\serialport\src\serialport.cpp(336):
warning C4996: 'Nan::Callback::Call': was declared deprecated [C:\Users\P51QHM
IPC00.node-red\node_modules\serialport\build\serialport.vcxproj]
c:\users\p51qhmipc00.node-red\node_modules\nan\nan.h(1740): note: see declar
ation of 'Nan::Callback::Call'
c:\users\p51qhmipc00.node-red\node_modules\serialport\src\serialport.cpp(383):
warning C4996: 'Nan::Callback::Call': was declared deprecated [C:\Users\P51QHM
IPC00.node-red\node_modules\serialport\build\serialport.vcxproj]
c:\users\p51qhmipc00.node-red\node_modules\nan\nan.h(1740): note: see declar
ation of 'Nan::Callback::Call'
c:\users\p51qhmipc00.node-red\node_modules\serialport\src\serialport.cpp(424):
warning C4996: 'Nan::Callback::Call': was declared deprecated [C:\Users\P51QHM
IPC00.node-red\node_modules\serialport\build\serialport.vcxproj]
c:\users\p51qhmipc00.node-red\node_modules\nan\nan.h(1740): note: see declar
ation of 'Nan::Callback::Call'
c:\users\p51qhmipc00.node-red\node_modules\serialport\src\serialport_win.cpp(1
83): warning C4311: 'type cast': pointer truncation from 'HANDLE' to 'int' [C:
Users\P51QHMIPC00.node-red\node_modules\serialport\build\serialport.vcxproj]
c:\users\p51qhmipc00.node-red\node_modules\serialport\src\serialport_win.cpp(1
83): warning C4302: 'type cast': truncation from 'HANDLE' to 'int' [C:\Users\P5
1QHMIPC00.node-red\node_modules\serialport\build\serialport.vcxproj]
c:\users\p51qhmipc00.node-red\node_modules\serialport\src\serialport_win.cpp(1
93): warning C4312: 'type cast': conversion from 'int' to 'HANDLE' of greater s
ize [C:\Users\P51QHMIPC00.node-red\node_modules\serialport\build\serialport.vc
xproj]
c:\users\p51qhmipc00.node-red\node_modules\serialport\src\serialport_win.cpp(2
00): warning C4312: 'type cast': conversion from 'int' to 'HANDLE' of greater s
ize [C:\Users\P51QHMIPC00.node-red\node_modules\serialport\build\serialport.vc
xproj]
c:\users\p51qhmipc00.node-red\node_modules\serialport\src\serialport_win.cpp(2
10): warning C4312: 'type cast': conversion from 'int' to 'HANDLE' of greater s
ize [C:\Users\P51QHMIPC00.node-red\node_modules\serialport\build\serialport.vc
xproj]
c:\users\p51qhmipc00.node-red\node_modules\serialport\src\serialport_win.cpp(2
12): warning C4312: 'type cast': conversion from 'int' to 'HANDLE' of greater s
ize [C:\Users\P51QHMIPC00.node-red\node_modules\serialport\build\serialport.vc
xproj]
c:\users\p51qhmipc00.node-red\node_modules\serialport\src\serialport_win.cpp(2
16): warning C4312: 'type cast': conversion from 'int' to 'HANDLE' of greater s
ize [C:\Users\P51QHMIPC00.node-red\node_modules\serialport\build\serialport.vc
xproj]
c:\users\p51qhmipc00.node-red\node_modules\serialport\src\serialport_win.cpp(2
18): warning C4312: 'type cast': conversion from 'int' to 'HANDLE' of greater s
ize [C:\Users\P51QHMIPC00.node-red\node_modules\serialport\build\serialport.vc
xproj]
c:\users\p51qhmipc00.node-red\node_modules\serialport\src\serialport_win.cpp(2
22): warning C4312: 'type cast': conversion from 'int' to 'HANDLE' of greater s
ize [C:\Users\P51QHMIPC00.node-red\node_modules\serialport\build\serialport.vc
xproj]
c:\users\p51qhmipc00.node-red\node_modules\serialport\src\serialport_win.cpp(2
24): warning C4312: 'type cast': conversion from 'int' to 'HANDLE' of greater s
ize [C:\Users\P51QHMIPC00.node-red\node_modules\serialport\build\serialport.vc
xproj]
c:\users\p51qhmipc00.node-red\node_modules\serialport\src\serialport_win.cpp(2
29): warning C4312: 'type cast': conversion from 'int' to 'HANDLE' of greater s
ize [C:\Users\P51QHMIPC00.node-red\node_modules\serialport\build\serialport.vc
xproj]
c:\users\p51qhmipc00.node-red\node_modules\serialport\src\serialport_win.cpp(2
41): warning C4312: 'type cast': conversion from 'int' to 'HANDLE' of greater s
ize [C:\Users\P51QHMIPC00.node-red\node_modules\serialport\build\serialport.vc
xproj]
c:\users\p51qhmipc00.node-red\node_modules\serialport\src\serialport_win.cpp(2
51): warning C4312: 'type cast': conversion from 'int' to 'HANDLE' of greater s
ize [C:\Users\P51QHMIPC00.node-red\node_modules\serialport\build\serialport.vc
xproj]
c:\users\p51qhmipc00.node-red\node_modules\serialport\src\serialport_win.cpp(2
68): warning C4312: 'type cast': conversion from 'int' to 'HANDLE' of greater s
ize [C:\Users\P51QHMIPC00.node-red\node_modules\serialport\build\serialport.vc
xproj]
c:\users\p51qhmipc00.node-red\node_modules\serialport\src\serialport_win.cpp(2
99): warning C4996: 'v8::Value::ToObject': was declared deprecated [C:\Users\P5
1QHMIPC00.node-red\node_modules\serialport\build\serialport.vcxproj]
c:\users\p51qhmipc00.node-gyp\10.16.3\include\node\v8.h(10046): note: see de
claration of 'v8::Value::ToObject'
c:\users\p51qhmipc00.node-red\node_modules\serialport\src\serialport_win.cpp(3
29): warning C4312: 'type cast': conversion from 'int' to 'HANDLE' of greater s
ize [C:\Users\P51QHMIPC00.node-red\node_modules\serialport\build\serialport.vc
xproj]
c:\users\p51qhmipc00.node-red\node_modules\serialport\src\serialport_win.cpp(3
55): warning C4312: 'type cast': conversion from 'int' to 'HANDLE' of greater s
ize [C:\Users\P51QHMIPC00.node-red\node_modules\serialport\build\serialport.vc
xproj]
c:\users\p51qhmipc00.node-red\node_modules\serialport\src\serialport_win.cpp(3
84): warning C4996: 'Nan::Callback::Call': was declared deprecated [C:\Users\P5
1QHMIPC00.node-red\node_modules\serialport\build\serialport.vcxproj]
c:\users\p51qhmipc00.node-red\node_modules\nan\nan.h(1740): note: see declar
ation of 'Nan::Callback::Call'
c:\users\p51qhmipc00.node-red\node_modules\serialport\src\serialport_win.cpp(4
01): warning C4996: 'v8::Value::ToObject': was declared deprecated [C:\Users\P5
1QHMIPC00.node-red\node_modules\serialport\build\serialport.vcxproj]
c:\users\p51qhmipc00.node-gyp\10.16.3\include\node\v8.h(10046): note: see de
claration of 'v8::Value::ToObject'
c:\users\p51qhmipc00.node-red\node_modules\serialport\src\serialport_win.cpp(4
56): warning C4312: 'type cast': conversion from 'int' to 'HANDLE' of greater s
ize [C:\Users\P51QHMIPC00.node-red\node_modules\serialport\build\serialport.vc
xproj]
c:\users\p51qhmipc00.node-red\node_modules\serialport\src\serialport_win.cpp(4
73): warning C4312: 'type cast': conversion from 'int' to 'HANDLE' of greater s
ize [C:\Users\P51QHMIPC00.node-red\node_modules\serialport\build\serialport.vc
xproj]
c:\users\p51qhmipc00.node-red\node_modules\serialport\src\serialport_win.cpp(4
86): warning C4312: 'type cast': conversion from 'int' to 'HANDLE' of greater s
ize [C:\Users\P51QHMIPC00.node-red\node_modules\serialport\build\serialport.vc
xproj]
c:\users\p51qhmipc00.node-red\node_modules\serialport\src\serialport_win.cpp(4
96): warning C4312: 'type cast': conversion from 'int' to 'HANDLE' of greater s
ize [C:\Users\P51QHMIPC00.node-red\node_modules\serialport\build\serialport.vc
xproj]
c:\users\p51qhmipc00.node-red\node_modules\serialport\src\serialport_win.cpp(5
24): warning C4312: 'type cast': conversion from 'int' to 'HANDLE' of greater s
ize [C:\Users\P51QHMIPC00.node-red\node_modules\serialport\build\serialport.vc
xproj]
c:\users\p51qhmipc00.node-red\node_modules\serialport\src\serialport_win.cpp(5
35): warning C4312: 'type cast': conversion from 'int' to 'HANDLE' of greater s
ize [C:\Users\P51QHMIPC00.node-red\node_modules\serialport\build\serialport.vc
xproj]
c:\users\p51qhmipc00.node-red\node_modules\serialport\src\serialport_win.cpp(5
67): warning C4996: 'Nan::Callback::Call': was declared deprecated [C:\Users\P5
1QHMIPC00.node-red\node_modules\serialport\build\serialport.vcxproj]
c:\users\p51qhmipc00.node-red\node_modules\nan\nan.h(1740): note: see declar
ation of 'Nan::Callback::Call'
c:\users\p51qhmipc00.node-red\node_modules\serialport\src\serialport_win.cpp(5
83): warning C4312: 'type cast': conversion from 'int' to 'HANDLE' of greater s
ize [C:\Users\P51QHMIPC00.node-red\node_modules\serialport\build\serialport.vc
xproj]
c:\users\p51qhmipc00.node-red\node_modules\serialport\src\serialport_win.cpp(5
85): warning C4312: 'type cast': conversion from 'int' to 'HANDLE' of greater s
ize [C:\Users\P51QHMIPC00.node-red\node_modules\serialport\build\serialport.vc
xproj]
c:\users\p51qhmipc00.node-red\node_modules\serialport\src\serialport_win.cpp(7
49): warning C4996: 'Nan::Callback::Call': was declared deprecated [C:\Users\P5
1QHMIPC00.node-red\node_modules\serialport\build\serialport.vcxproj]
c:\users\p51qhmipc00.node-red\node_modules\nan\nan.h(1740): note: see declar
ation of 'Nan::Callback::Call'
c:\users\p51qhmipc00.node-red\node_modules\serialport\src\serialport_win.cpp(7
63): warning C4312: 'type cast': conversion from 'int' to 'HANDLE' of greater s
ize [C:\Users\P51QHMIPC00.node-red\node_modules\serialport\build\serialport.vc
xproj]
c:\users\p51qhmipc00.node-red\node_modules\serialport\src\serialport_win.cpp(7
72): warning C4312: 'type cast': conversion from 'int' to 'HANDLE' of greater s
ize [C:\Users\P51QHMIPC00.node-red\node_modules\serialport\build\serialport.vc
xproj]
win_delay_load_hook.cc
Creating library C:\Users\P51QHMIPC00.node-red\node_modules\serialport\bu
ild\Release\serialport.lib and object C:\Users\P51QHMIPC00.node-red\node_mod
ules\serialport\build\Release\serialport.exp
Generating code
All 467 functions were compiled because no usable IPDB/IOBJ from previous com
pilation was found.
Finished generating code
serialport.vcxproj -> C:\Users\P51QHMIPC00.node-red\node_modules\serialport
build\Release\serialport.node

  • node-red-contrib-modbus@3.6.1
    added 145 packages from 58 contributors and audited 1668 packages in 69.601s
    found 39 vulnerabilities (12 low, 25 high, 2 critical)
    run npm audit fix to fix them, or npm audit for details

C:\Users\P51QHMIPC00.node-red>

Well after adding the environment variable path, I successfully have the 3.6.1 version of the

contrib-modbus, However, I am still having issues with it, I believe for the sake of this topic, the solution is found. Thanks for all the help.

1 Like