Error installing node-red-node-arduino on Windows 10

I was trying to follow the instruction at Interacting with Arduino : Node-RED to interface arduino with node-red. Until now, I've installed node-red, and loaded the firmata firmware on the board.
When I'm trying to install node-red-node-arduino using npm install node-red-node-arduino in the .node-red directory, I get build errors.

Node-red and NPM version:

30 Sep 20:49:43 - [info] Node-RED version: v2.0.6
30 Sep 20:49:43 - [info] Node.js  version: v12.14.0
30 Sep 20:49:43 - [info] Windows_NT 10.0.19043 x64 LE

The error message is:

npm ERR! code 1
npm ERR! path C:\Users\kumar\.node-red\node_modules\@serialport\bindings
npm ERR! command failed
npm ERR! command C:\WINDOWS\system32\cmd.exe /d /s /c prebuild-install --tag-prefix @serialport/bindings@ || node-gyp rebuild
npm ERR! Building the projects in this solution one at a time. To enable parallel build, please add the "-m" switch.
npm ERR!   serialport.cpp
npm ERR!   serialport_win.cpp
npm ERR!   win_delay_load_hook.cc
npm ERR! C:\\Users\\kumar\\AppData\\Local\\node-gyp\\Cache\\12.14.0\\x64\\node.lib : fatal error LNK1107: invalid or corrupt file: cannot read at 0x4B662D [C:\Users\kumar\.node-red\node_modules\@serialport\bindings\build\bindings.vcxproj]
npm ERR! gyp info it worked if it ends with ok
npm ERR! gyp info using node-gyp@7.1.2
npm ERR! gyp info using node@12.14.0 | win32 | x64
npm ERR! gyp info find Python using Python version 3.9.7 found at "C:\Users\kumar\AppData\Local\Programs\Python\Python39-64\python.exe"
npm ERR! gyp info find VS using VS2019 (16.10.31410.357) found at:
npm ERR! gyp info find VS "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community"
npm ERR! gyp info find VS run with --verbose for detailed information
npm ERR! gyp info spawn C:\Users\kumar\AppData\Local\Programs\Python\Python39-64\python.exe
npm ERR! gyp info spawn args [
npm ERR! gyp info spawn args   'C:\\Users\\kumar\\AppData\\Roaming\\npm\\node_modules\\npm\\node_modules\\node-gyp\\gyp\\gyp_main.py',
npm ERR! gyp info spawn args   'binding.gyp',
npm ERR! gyp info spawn args   '-f',
npm ERR! gyp info spawn args   'msvs',
npm ERR! gyp info spawn args   '-I',
npm ERR! gyp info spawn args   'C:\\Users\\kumar\\.node-red\\node_modules\\@serialport\\bindings\\build\\config.gypi',
npm ERR! gyp info spawn args   '-I',
npm ERR! gyp info spawn args   'C:\\Users\\kumar\\AppData\\Roaming\\npm\\node_modules\\npm\\node_modules\\node-gyp\\addon.gypi',
npm ERR! gyp info spawn args   '-I',
npm ERR! gyp info spawn args   'C:\\Users\\kumar\\AppData\\Local\\node-gyp\\Cache\\12.14.0\\include\\node\\common.gypi',npm ERR! gyp info spawn args   '-Dlibrary=shared_library',
npm ERR! gyp info spawn args   '-Dvisibility=default',
npm ERR! gyp info spawn args   '-Dnode_root_dir=C:\\Users\\kumar\\AppData\\Local\\node-gyp\\Cache\\12.14.0',
npm ERR! gyp info spawn args   '-Dnode_gyp_dir=C:\\Users\\kumar\\AppData\\Roaming\\npm\\node_modules\\npm\\node_modules\\node-gyp',
npm ERR! gyp info spawn args   '-Dnode_lib_file=C:\\\\Users\\\\kumar\\\\AppData\\\\Local\\\\node-gyp\\\\Cache\\\\12.14.0\\\\<(target_arch)\\\\node.lib',
npm ERR! gyp info spawn args   '-Dmodule_root_dir=C:\\Users\\kumar\\.node-red\\node_modules\\@serialport\\bindings',
npm ERR! gyp info spawn args   '-Dnode_engine=v8',
npm ERR! gyp info spawn args   '--depth=.',
npm ERR! gyp info spawn args   '--no-parallel',
npm ERR! gyp info spawn args   '--generator-output',
npm ERR! gyp info spawn args   'C:\\Users\\kumar\\.node-red\\node_modules\\@serialport\\bindings\\build',
npm ERR! gyp info spawn args   '-Goutput_dir=.'
npm ERR! gyp info spawn args ]
npm ERR! gyp info spawn C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Current\Bin\MSBuild.exe
npm ERR! gyp info spawn args [
npm ERR! gyp info spawn args   'build/binding.sln',
npm ERR! gyp info spawn args   '/clp:Verbosity=minimal',
npm ERR! gyp info spawn args   '/nologo',
npm ERR! gyp info spawn args   '/p:Configuration=Release;Platform=x64'
npm ERR! gyp info spawn args ]
npm ERR! gyp ERR! build error
npm ERR! gyp ERR! stack Error: `C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Current\Bin\MSBuild.exe` failed with exit code: 1
npm ERR! gyp ERR! stack     at ChildProcess.onExit (C:\Users\kumar\AppData\Roaming\npm\node_modules\npm\node_modules\node-gyp\lib\build.js:194:23)
npm ERR! gyp ERR! stack     at ChildProcess.emit (events.js:210:5)
npm ERR! gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:272:12)
npm ERR! gyp ERR! System Windows_NT 10.0.19043
npm ERR! gyp ERR! command "D:\\software installation\\nodejs\\node.exe" "C:\\Users\\kumar\\AppData\\Roaming\\npm\\node_modules\\npm\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild"
npm ERR! gyp ERR! cwd C:\Users\kumar\.node-red\node_modules\@serialport\bindings
npm ERR! gyp ERR! node -v v12.14.0
npm ERR! gyp ERR! node-gyp -v v7.1.2
npm ERR! gyp ERR! not ok

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\kumar\AppData\Local\npm-cache\_logs\2021-09-30T15_15_32_459Z-debug.log

I didn't have any other serial window or arduino ide windows open. Also, I've msvc c++ build chain installed.

What is the problem and how can I fix it?

Welcome to the forum @gyan

The npm cache may be currupt. Run (in the .node-red folder)
npm cache clean --force
And just in case
sudo npm -g cache clean --force
then try again.

I tried these commands, but it didn't work. I also tried manually deleting the cache folders, but that didn't work either.

Do you mean you still get exactly the same error?

Yeah, I got the same error.

npm ERR! code 1
npm ERR! path C:\Users\kumar\.node-red\node_modules\@serialport\bindings
npm ERR! command failed
npm ERR! command C:\WINDOWS\system32\cmd.exe /d /s /c prebuild-install --tag-prefix @serialport/bindings@ || node-gyp rebuild
npm ERR! Building the projects in this solution one at a time. To enable parallel build, please add the "-m" switch.
npm ERR!   serialport.cpp
npm ERR!   serialport_win.cpp
npm ERR!   win_delay_load_hook.cc
npm ERR! C:\\Users\\kumar\\AppData\\Local\\node-gyp\\Cache\\12.14.0\\x64\\node.lib : fatal error LNK1107: invalid or corrupt file: cannot read at 0x4B662D [C:\Users\kumar\.node-red\node_modules\@serialport\bindings\build\bindings.vcxproj]
npm ERR! gyp info it worked if it ends with ok
npm ERR! gyp info using node-gyp@7.1.2
npm ERR! gyp info using node@12.14.0 | win32 | x64
npm ERR! gyp info find Python using Python version 3.9.7 found at "C:\Users\kumar\AppData\Local\Programs\Python\Python39-64\python.exe"
npm ERR! gyp info find VS using VS2019 (16.10.31410.357) found at:
npm ERR! gyp info find VS "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community"
npm ERR! gyp info find VS run with --verbose for detailed information
npm ERR! gyp info spawn C:\Users\kumar\AppData\Local\Programs\Python\Python39-64\python.exe
npm ERR! gyp info spawn args [
npm ERR! gyp info spawn args   'C:\\Users\\kumar\\AppData\\Roaming\\npm\\node_modules\\npm\\node_modules\\node-gyp\\gyp\\gyp_main.py',
npm ERR! gyp info spawn args   'binding.gyp',
npm ERR! gyp info spawn args   '-f',
npm ERR! gyp info spawn args   'msvs',
npm ERR! gyp info spawn args   '-I',
npm ERR! gyp info spawn args   'C:\\Users\\kumar\\.node-red\\node_modules\\@serialport\\bindings\\build\\config.gypi',
npm ERR! gyp info spawn args   '-I',
npm ERR! gyp info spawn args   'C:\\Users\\kumar\\AppData\\Roaming\\npm\\node_modules\\npm\\node_modules\\node-gyp\\addon.gypi',
npm ERR! gyp info spawn args   '-I',
npm ERR! gyp info spawn args   'C:\\Users\\kumar\\AppData\\Local\\node-gyp\\Cache\\12.14.0\\include\\node\\common.gypi',
npm ERR! gyp info spawn args   '-Dlibrary=shared_library',
npm ERR! gyp info spawn args   '-Dvisibility=default',
npm ERR! gyp info spawn args   '-Dnode_root_dir=C:\\Users\\kumar\\AppData\\Local\\node-gyp\\Cache\\12.14.0',
npm ERR! gyp info spawn args   '-Dnode_gyp_dir=C:\\Users\\kumar\\AppData\\Roaming\\npm\\node_modules\\npm\\node_modules\\node-gyp',
npm ERR! gyp info spawn args   '-Dnode_lib_file=C:\\\\Users\\\\kumar\\\\AppData\\\\Local\\\\node-gyp\\\\Cache\\\\12.14.0\\\\<(target_arch)\\\\node.lib',
npm ERR! gyp info spawn args   '-Dmodule_root_dir=C:\\Users\\kumar\\.node-red\\node_modules\\@serialport\\bindings',
npm ERR! gyp info spawn args   '-Dnode_engine=v8',
npm ERR! gyp info spawn args   '--depth=.',
npm ERR! gyp info spawn args   '--no-parallel',
npm ERR! gyp info spawn args   '--generator-output',
npm ERR! gyp info spawn args   'C:\\Users\\kumar\\.node-red\\node_modules\\@serialport\\bindings\\build',
npm ERR! gyp info spawn args   '-Goutput_dir=.'
npm ERR! gyp info spawn args ]
npm ERR! gyp info spawn C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Current\Bin\MSBuild.exe
npm ERR! gyp info spawn args [
npm ERR! gyp info spawn args   'build/binding.sln',
npm ERR! gyp info spawn args   '/clp:Verbosity=minimal',
npm ERR! gyp info spawn args   '/nologo',
npm ERR! gyp info spawn args   '/p:Configuration=Release;Platform=x64'
npm ERR! gyp info spawn args ]
npm ERR! gyp ERR! build error
npm ERR! gyp ERR! stack Error: `C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Current\Bin\MSBuild.exe` failed with exit code: 1
npm ERR! gyp ERR! stack     at ChildProcess.onExit (C:\Users\kumar\AppData\Roaming\npm\node_modules\npm\node_modules\node-gyp\lib\build.js:194:23)
npm ERR! gyp ERR! stack     at ChildProcess.emit (events.js:210:5)
npm ERR! gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:272:12)
npm ERR! gyp ERR! System Windows_NT 10.0.19043
npm ERR! gyp ERR! command "D:\\software installation\\nodejs\\node.exe" "C:\\Users\\kumar\\AppData\\Roaming\\npm\\node_modules\\npm\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild"
npm ERR! gyp ERR! cwd C:\Users\kumar\.node-red\node_modules\@serialport\bindings
npm ERR! gyp ERR! node -v v12.14.0
npm ERR! gyp ERR! node-gyp -v v7.1.2
npm ERR! gyp ERR! not ok

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\kumar\AppData\Local\npm-cache\_logs\2021-09-30T17_15_39_833Z-debug.log

Delete that folder if it exists, then run npm install. If that succeeds then try the node install again.

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