title: Can't compile Electron app under Windows, node-gyp fails to build cpu-features
body: <p>My Electron application compiles and packages under MacOS without any problems but when it comes to Windows, I can't seem to make it work.</p>
  <p>Here's the debug output:</p>
  <pre><code>Error: node-gyp failed to rebuild '[appfolder]\release\app\node_modules\cpu-features'.
  For more information, rerun with the DEBUG environment variable set to &quot;electron-rebuild&quot;.
  
  Error: `C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\MSBuild\Current\Bin\MSBuild.exe` failed with exit code: 1
  
  
      at NodeGyp.rebuildModule ([appfolder]\node_modules\electron-rebuild\lib\src\module-type\node-gyp.js:117:19)
      at processTicksAndRejections (internal/process/task_queues.js:95:5)
      at async ModuleRebuilder.rebuildNodeGypModule ([appfolder]\node_modules\electron-rebuild\lib\src\module-rebuilder.js:94:9)
      at async ModuleRebuilder.rebuild ([appfolder]\node_modules\electron-rebuild\lib\src\module-rebuilder.js:124:14)
      at async Rebuilder.rebuildModuleAt ([appfolder]\node_modules\electron-rebuild\lib\src\rebuild.js:145:13)
      at async Promise.all (index 7)
      at async Rebuilder.rebuild ([appfolder]\node_modules\electron-rebuild\lib\src\rebuild.js:104:13)
      at async [appfolder]\node_modules\electron-rebuild\lib\src\cli.js:154:9
  Error: Command failed: ..\..\node_modules\.bin\electron-rebuild --parallel --force --types prod,dev,optional --module-dir .
      at checkExecSyncError (child_process.js:790:11)
      at execSync (child_process.js:863:15)
      at Object.&lt;anonymous&gt; ([appfolder]\.erb\scripts\electron-rebuild.js:17:11)
      at Module._compile (internal/modules/cjs/loader.js:1085:14)
      at Module.m._compile ([appfolder]\node_modules\ts-node\src\index.ts:1455:23)
      at Module._extensions..js (internal/modules/cjs/loader.js:1114:10)
      at Object.require.extensions.&lt;computed&gt; [as .js] ([appfolder]\node_modules\ts-node\src\index.ts:1458:12)
      at Module.load (internal/modules/cjs/loader.js:950:32)
      at Function.Module._load (internal/modules/cjs/loader.js:790:12)
      at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:75:12) {
    status: 4294967295,
    signal: null,
    output: [ null, null, null ],
    pid: 2700,
    stdout: null,
    stderr: null
  }
  npm ERR! code ELIFECYCLE
  npm ERR! errno 1
  npm ERR! elapp@4.5.0 electron-rebuild: `node -r ts-node/register ../../.erb/scripts/electron-rebuild.js`
  npm ERR! Exit status 1
  npm ERR! 
  npm ERR! Failed at the elapp@4.5.0 electron-rebuild script.
  npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
  
  npm ERR! A complete log of this run can be found in:
  npm ERR!     C:\Users\elodie\AppData\Roaming\npm-cache\_logs\2022-04-17T20_38_46_086Z-debug.log
  error Command failed with exit code 1.
    failedTask=installAppDeps stackTrace=Error: C:\Program Files\nodejs\node.exe exited with code ERR_ELECTRON_BUILDER_CANNOT_EXECUTE
  Output:
  yarn install v1.22.18
  [1/4] Resolving packages...
  success Already up-to-date.
  $ npm run electron-rebuild &amp;&amp; npm run link-modules
  </code></pre>
  <p>Tried this with Node v14, 16 and 17 to no avail.</p>
  <p>EDIT: Missed the actual error while posting. Here's the error from C++ compilation step:</p>
  <pre><code>&gt; elapp@4.5.0 electron-rebuild [appfolder]\release\app
  &gt; node -r ts-node/register ../../.erb/scripts/electron-rebuild.js
  
  Building the projects in this solution one at a time. To enable parallel build, please add the &quot;-m&quot; switch.
  Building the projects in this solution one at a time. To enable parallel build, please add the &quot;-m&quot; switch.
    conpty.cc
    conpty.cc
  [appfolder]\release\app\node_modules\node-pty\src\win\conpty.cc : fatal error C1083: Cannot open compiler generated file: '[folder]\obj\conpty\src\win\conpty.obj': Permission denied [[appfolder]\release\app\node_modules\node-pty\build\conpty.vcxproj]
    path_util.cc
    conpty_console_list.cc
    win_delay_load_hook.cc
    win_delay_load_hook.cc
       Creating library [folder]\conpty_console_list.lib and object [folder]\conpty_console_list.exp
       Creating library [folder]\conpty.lib and object [folder]\conpty.exp
    conpty_console_list.vcxproj -&gt; [folder]\\conpty_console_list.node
    conpty.vcxproj -&gt; [folder]\\conpty.node
    Agent.cc
    conpty_console_list.vcxproj -&gt; [folder]\\conpty_console_list.node
    Agent.cc
  [appfolder]\release\app\node_modules\node-pty\deps\winpty\src\agent\Agent.cc : fatal error C1083: Cannot open compiler generated file: '[appfolder]\release\app\node_modules\node-pty\build\deps\winpty\src\Release\obj\winpty-agent\deps\winpty\src\agent\Agent.obj': Permission denied [[appfolder]\release\app\node_modules\node-pty\build\deps\winpty\src\winpty-agent.vcxproj]
  </code></pre>
  <p>EDIT 2: Running the same command as an administrator lead to another error:</p>
  <pre><code>yarn install v1.22.18
  [1/4] Resolving packages...
  success Already up-to-date.
  $ npm run electron-rebuild &amp;&amp; npm run link-modules
  
  &gt; elapp@4.5.0 electron-rebuild C:\Users\elodie\Projects\elapp\release\app
  &gt; node -r ts-node/register ../../.erb/scripts/electron-rebuild.js
  
  info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command.
  
  Error output:
  - Searching dependency tree
  The process cannot access the file because it is being used by another process.
  The process cannot access the file because it is being used by another process.
  gyp: Call to 'cmd /c &quot;cd shared &amp;&amp; UpdateGenVersion.bat 2c681018ca7311741a0022e3a170bf60174590b2&quot;' returned exit status 0 while in deps\winpty\src\winpty.gyp. while loading dependencies of binding.gyp while trying to load binding.gyp
  × Rebuild Failed
  
  An unhandled error occurred inside electron-rebuild
  node-gyp failed to rebuild 'C:\Users\elodie\Projects\elapp\release\app\node_modules\node-pty'.
  For more information, rerun with the DEBUG environment variable set to &quot;electron-rebuild&quot;.
  
  Error: `gyp` failed with exit code: 1
  </code></pre>