Search code examples
node.jswindowsnpmnpm-installnode-red

NPM Err! 1 NPM ERR! When installing package


I get this error when I try to install the package "node-red-node-arduino". Here's the full log:

PS C:\Users\User\.node-red> npm i --unsafe-perm node-red-node-arduino
npm ERR! code 1
npm ERR! path C:\Users\User\.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! gyp info it worked if it ends with ok
npm ERR! gyp info using node-gyp@9.4.0
npm ERR! gyp info using node@20.9.0 | win32 | x64
npm ERR! gyp info find Python using Python version 3.12.0 found at "C:\Users\User\AppData\Local\Programs\Python\Python312\python.exe"
npm ERR! gyp ERR! find VS
npm ERR! gyp ERR! find VS msvs_version not set from command line or npm config
npm ERR! gyp ERR! find VS VCINSTALLDIR not set, not running in VS Command Prompt
npm ERR! gyp ERR! find VS could not use PowerShell to find Visual Studio 2017 or newer, try re-running with '--loglevel silly' for more details
npm ERR! gyp ERR! find VS not looking for VS2015 as it is only supported up to Node.js 18
npm ERR! gyp ERR! find VS not looking for VS2013 as it is only supported up to Node.js 8
npm ERR! gyp ERR! find VS
npm ERR! gyp ERR! find VS **************************************************************
npm ERR! gyp ERR! find VS You need to install the latest version of Visual Studio
npm ERR! gyp ERR! find VS including the "Desktop development with C++" workload.
npm ERR! gyp ERR! find VS For more information consult the documentation at:
npm ERR! gyp ERR! find VS https://github.com/nodejs/node-gyp#on-windows
npm ERR! gyp ERR! find VS **************************************************************
npm ERR! gyp ERR! find VS
npm ERR! gyp ERR! configure error
npm ERR! gyp ERR! stack Error: Could not find any Visual Studio installation to use
npm ERR! gyp ERR! stack     at VisualStudioFinder.fail (C:\Users\User\AppData\Roaming\nvm\v20.9.0\node_modules\npm\node_modules\node-gyp\lib\find-visualstudio.js:122:47)
npm ERR! gyp ERR! stack     at C:\Users\User\AppData\Roaming\nvm\v20.9.0\node_modules\npm\node_modules\node-gyp\lib\find-visualstudio.js:75:16
npm ERR! gyp ERR! stack     at VisualStudioFinder.findVisualStudio2013 (C:\Users\User\AppData\Roaming\nvm\v20.9.0\node_modules\npm\node_modules\node-gyp\lib\find-visualstudio.js:380:14)
npm ERR! gyp ERR! stack     at C:\Users\User\AppData\Roaming\nvm\v20.9.0\node_modules\npm\node_modules\node-gyp\lib\find-visualstudio.js:71:14
npm ERR! gyp ERR! stack     at VisualStudioFinder.findVisualStudio2015 (C:\Users\User\AppData\Roaming\nvm\v20.9.0\node_modules\npm\node_modules\node-gyp\lib\find-visualstudio.js:364:14)
npm ERR! gyp ERR! stack     at C:\Users\User\AppData\Roaming\nvm\v20.9.0\node_modules\npm\node_modules\node-gyp\lib\find-visualstudio.js:67:12
npm ERR! gyp ERR! stack     at failPowershell (C:\Users\User\AppData\Roaming\nvm\v20.9.0\node_modules\npm\node_modules\node-gyp\lib\find-visualstudio.js:156:7)
npm ERR! gyp ERR! stack     at VisualStudioFinder.parseData (C:\Users\User\AppData\Roaming\nvm\v20.9.0\node_modules\npm\node_modules\node-gyp\lib\find-visualstudio.js:170:14)
npm ERR! gyp ERR! stack     at C:\Users\User\AppData\Roaming\nvm\v20.9.0\node_modules\npm\node_modules\node-gyp\lib\find-visualstudio.js:143:14
npm ERR! gyp ERR! stack     at ChildProcess.exithandler (node:child_process:414:7)
npm ERR! gyp ERR! System Windows_NT 10.0.19045
npm ERR! gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "C:\\Users\\User\\AppData\\Roaming\\nvm\\v20.9.0\\node_modules\\npm\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild"
npm ERR! gyp ERR! cwd C:\Users\User\.node-red\node_modules\@serialport\bindings
npm ERR! gyp ERR! node -v v20.9.0
npm ERR! gyp ERR! node-gyp -v v9.4.0
npm ERR! gyp ERR! not ok

npm ERR! A complete log of this run can be found in: C:\Users\User\AppData\Local\npm-cache\_logs\2023-11-14T13_20_45_527Z-debug-0.log

I've installed node and NPM through NVM, through the command "nvm install 20.9.0", 20.9.0 is what they say is the last stable version of node.

Edit 1: Installed VS Code and restarted the computer and still got this result:

PS C:\Users\User\.node-red> npm i -g --unsafe-perm node-red-node-arduino
npm ERR! code 1
npm ERR! path C:\Users\User\AppData\Roaming\nvm\v20.9.0\node_modules\node-red-node-arduino\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! gyp info it worked if it ends with ok
npm ERR! gyp info using node-gyp@9.4.0
npm ERR! gyp info using node@20.9.0 | win32 | x64
npm ERR! gyp info find Python using Python version 3.12.0 found at "C:\Users\User\AppData\Local\Programs\Python\Python312\python.exe"
npm ERR! gyp ERR! find VS
npm ERR! gyp ERR! find VS msvs_version not set from command line or npm config
npm ERR! gyp ERR! find VS VCINSTALLDIR not set, not running in VS Command Prompt
npm ERR! gyp ERR! find VS could not use PowerShell to find Visual Studio 2017 or newer, try re-running with '--loglevel silly' for more details
npm ERR! gyp ERR! find VS not looking for VS2015 as it is only supported up to Node.js 18
npm ERR! gyp ERR! find VS not looking for VS2013 as it is only supported up to Node.js 8
npm ERR! gyp ERR! find VS
npm ERR! gyp ERR! find VS **************************************************************
npm ERR! gyp ERR! find VS You need to install the latest version of Visual Studio
npm ERR! gyp ERR! find VS including the "Desktop development with C++" workload.
npm ERR! gyp ERR! find VS For more information consult the documentation at:
npm ERR! gyp ERR! find VS https://github.com/nodejs/node-gyp#on-windows
npm ERR! gyp ERR! find VS **************************************************************
npm ERR! gyp ERR! find VS
npm ERR! gyp ERR! configure error
npm ERR! gyp ERR! stack Error: Could not find any Visual Studio installation to use
npm ERR! gyp ERR! stack     at VisualStudioFinder.fail (C:\Users\User\AppData\Roaming\nvm\v20.9.0\node_modules\npm\node_modules\node-gyp\lib\find-visualstudio.js:122:47)
npm ERR! gyp ERR! stack     at C:\Users\User\AppData\Roaming\nvm\v20.9.0\node_modules\npm\node_modules\node-gyp\lib\find-visualstudio.js:75:16
npm ERR! gyp ERR! stack     at VisualStudioFinder.findVisualStudio2013 (C:\Users\User\AppData\Roaming\nvm\v20.9.0\node_modules\npm\node_modules\node-gyp\lib\find-visualstudio.js:380:14)
npm ERR! gyp ERR! stack     at C:\Users\User\AppData\Roaming\nvm\v20.9.0\node_modules\npm\node_modules\node-gyp\lib\find-visualstudio.js:71:14
npm ERR! gyp ERR! stack     at VisualStudioFinder.findVisualStudio2015 (C:\Users\User\AppData\Roaming\nvm\v20.9.0\node_modules\npm\node_modules\node-gyp\lib\find-visualstudio.js:364:14)
npm ERR! gyp ERR! stack     at C:\Users\User\AppData\Roaming\nvm\v20.9.0\node_modules\npm\node_modules\node-gyp\lib\find-visualstudio.js:67:12
npm ERR! gyp ERR! stack     at failPowershell (C:\Users\User\AppData\Roaming\nvm\v20.9.0\node_modules\npm\node_modules\node-gyp\lib\find-visualstudio.js:156:7)
npm ERR! gyp ERR! stack     at VisualStudioFinder.parseData (C:\Users\User\AppData\Roaming\nvm\v20.9.0\node_modules\npm\node_modules\node-gyp\lib\find-visualstudio.js:170:14)
npm ERR! gyp ERR! stack     at C:\Users\User\AppData\Roaming\nvm\v20.9.0\node_modules\npm\node_modules\node-gyp\lib\find-visualstudio.js:143:14
npm ERR! gyp ERR! stack     at ChildProcess.exithandler (node:child_process:414:7)
npm ERR! gyp ERR! System Windows_NT 10.0.19045
npm ERR! gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "C:\\Users\\User\\AppData\\Roaming\\nvm\\v20.9.0\\node_modules\\npm\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild"
npm ERR! gyp ERR! cwd C:\Users\User\AppData\Roaming\nvm\v20.9.0\node_modules\node-red-node-arduino\node_modules\@serialport\bindings
npm ERR! gyp ERR! node -v v20.9.0
npm ERR! gyp ERR! node-gyp -v v9.4.0
npm ERR! gyp ERR! not ok

npm ERR! A complete log of this run can be found in: C:\Users\User\AppData\Local\npm-cache\_logs\2023-11-14T16_45_22_153Z-debug-0.log

Solution

  • npm ERR! gyp ERR! find VS including the "Desktop development with C++" workload. npm ERR! gyp ERR! find VS For more information consult the documentation at:

    As stated here, I had to install Visual Studio(not VS code as I tought at first) checking the option to install "Desktop development with C++"

    Visual Studio Window with the options of installation expanded and an arrow pointing to the checkbox of "Desktop development with C++"

    Thanks to @esqew, who helped me find the solution.