robotjs: Cannot install using NPM

Failing to install the package using NPM (windows-build-tools installation just freezes on my pc so I used chocolatey to get them, but it didn’t work and I still get the error)

Expected Behavior

The package installs successfully

Current Behavior

Getting this error while trying to install the package:

npm ERR! code 7
npm ERR! path C:\Users\User\Desktop\rjs\node_modules\robotjs
npm ERR! command failed
npm ERR! command C:\WINDOWS\system32\cmd.exe /d /s /c prebuild-install || node-gyp rebuild
npm ERR! gyp info it worked if it ends with ok
npm ERR! gyp info using node-gyp@9.3.1
npm ERR! gyp info using node@16.14.0 | win32 | x64
npm ERR! gyp info find Python using Python version 3.10.7 found at "C:\Users\User\AppData\Local\Programs\Python\Python310\python.exe"
npm ERR! gyp info find VS using VS2022 (17.3.32819.101) found at:
npm ERR! gyp info find VS "C:\Program Files\Microsoft Visual Studio\2022\Community"
npm ERR! gyp info find VS run with --verbose for detailed information
npm ERR! gyp info spawn C:\Users\User\AppData\Local\Programs\Python\Python310\python.exe
npm ERR! gyp info spawn args [
npm ERR! gyp info spawn args   'C:\\Users\\User\\Desktop\\rjs\\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\\User\\Desktop\\rjs\\node_modules\\robotjs\\build\\config.gypi',
npm ERR! gyp info spawn args   '-I',
npm ERR! gyp info spawn args   'C:\\Users\\User\\Desktop\\rjs\\node_modules\\node-gyp\\addon.gypi',
npm ERR! gyp info spawn args   '-I',
npm ERR! gyp info spawn args   'C:\\Users\\User\\AppData\\Local\\node-gyp\\Cache\\16.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\\User\\AppData\\Local\\node-gyp\\Cache\\16.14.0',
npm ERR! gyp info spawn args   '-Dnode_gyp_dir=C:\\Users\\User\\Desktop\\rjs\\node_modules\\node-gyp',
npm ERR! gyp info spawn args   '-Dnode_lib_file=C:\\\\Users\\\\User\\\\AppData\\\\Local\\\\node-gyp\\\\Cache\\\\16.14.0\\\\<(target_arch)\\\\node.lib',
npm ERR! gyp info spawn args   '-Dmodule_root_dir=C:\\Users\\User\\Desktop\\rjs\\node_modules\\robotjs',
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\\User\\Desktop\\rjs\\node_modules\\robotjs\\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! UNCAUGHT EXCEPTION
npm ERR! gyp ERR! stack Error: spawn C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Current\Bin\MSBuild.exe ENOENT
npm ERR! gyp ERR! stack     at Process.ChildProcess._handle.onexit (node:internal/child_process:283:19)
npm ERR! gyp ERR! stack     at onErrorNT (node:internal/child_process:478:16)
npm ERR! gyp ERR! stack     at processTicksAndRejections (node:internal/process/task_queues:83:21)
npm ERR! gyp ERR! System Windows_NT 10.0.19045
npm ERR! gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "C:\\Users\\User\\Desktop\\rjs\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild"
npm ERR! gyp ERR! cwd C:\Users\User\Desktop\rjs\node_modules\robotjs
npm ERR! gyp ERR! node -v v16.14.0
npm ERR! gyp ERR! node-gyp -v v9.3.1
npm ERR! gyp ERR! Node-gyp failed to build your package.
npm ERR! gyp ERR! Try to update npm and/or node-gyp and if it does not help file an issue with the package author.

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

Steps to Reproduce (for bugs)

  1. npm i robotjs

Your Environment

  • RobotJS version: v0.6.0
  • Node.js version: v16.14.0
  • npm version: v8.3.1
  • Operating System: Windows 10 (10.0.19045.2486)

About this issue

  • Original URL
  • State: open
  • Created 4 years ago
  • Reactions: 8
  • Comments: 15

Most upvoted comments

@ashutoshtiwari199 Without additional info I can only recommend to give https://github.com/nut-tree/nut.js a try.

I met almost the same problem. This is how I solved it。

npm install --global --production windows-build-tools npm install node-gyp --global go this install Visual Studio
choose use c++ desktop dev then install。 The above installation sequence may be different. Now you can install robotjs。 install windows-build-tools maybe need admin。

I did the following installation: sudo apt-get install libxtst-dev libpng++-dev python3 python-is-python3 gcc (WSL2) and it solved it for me

@Antix-Development Happy to hear 😊. I’m just occasionally checking in here to see if I can answer some issues.