node-gyp: Call to 'node -e "require('nan')"' returned exit status 0 while in binding.gyp

  • Node Version: I’ve tried 15.0.0, 8.17.0, 12.21.0 and 14.15.5
  • Platform: Windows 10
  • Module: robotjs
I'm trying to install robotjs and its been 2 days without any luck, constantly getting this error. I have even copy pasted nan module in node-gyp node_modules and robotjs node_modules and it is still not installing nor rebuilding
gyp: Call to 'node -e "require('nan')"' returned exit status 0 while in 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:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\lib\configure.js:351:16)
gyp ERR! stack     at emitTwo (events.js:126:13)
gyp ERR! stack     at ChildProcess.emit (events.js:214:7)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:198:12)
gyp ERR! System Windows_NT 10.0.18363
my package.json ``` { "name": "MY SECRET PROJECT NAME", "version": "1.0.0", "description": "", "main": "main.js", "scripts": { "test": "echo \"Error: no test specified\" && exit 1", "start": "electron ." }, "author": "", "license": "ISC", "dependencies": { "electron-prompt": "^1.6.1", "electron-store": "^7.0.2", "iohook": "^0.7.2", "puppeteer": "^7.1.0", "robotjs": "^0.6.0" }, "devDependencies": { "electron": "^11.3.0" }, "iohook": { "targets": [ "node-88", "electron-85" ], "platforms": [ "win32" ], "arches": [ "x64", "ia32" ] } } ```

Current Workaround:

Make a new project with npm init then run npm i robotjs, you can also use .npmrc to download directly for electron like this:

``` runtime = electron target = 11.3.0 target_arch = ia32 disturl = https://atom.io/download/atom-shell ```
after downloading and on a new project robotjs will install successfully now copy everything inside your new project's `node_modules` folder and paste it in the project's `node_modules` in which it is not working. Lastly add `robotjs: 0.6.0` or the version you downloaded to the project's `package.json`

**Culprit: ** npm

Reasoning:

npm was removing packages when running npm install command so I think removed modules were required by robotjs, now I had to manually add them in node_modules folder.

**NOTE: ** You have to do this every time if you can’t run npm i robotjs, npm rebuild.

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Comments: 15 (4 by maintainers)

Most upvoted comments

Then why is it so difficult to create the requested failing test?

after removing .node-gyp cache, this issue magically disappear, I think it may be difficult to reproduce this issue in a clean environment.