title: How to force npm to use different node-gyp version when installing packages?
body: <p>I am running Node 16.13.2 LTS with Visual Studio 2022. During the installation of a package, node-gyp is triggered and fails.</p>
  <pre><code>npm ERR! command C:\WINDOWS\system32\cmd.exe /d /s /c node build.js || nodejs build.js
  npm ERR! gyp info it worked if it ends with ok
  npm ERR! gyp info using node-gyp@8.3.0
  npm ERR! gyp info using node@16.13.2 | win32 | x64
  npm ERR! gyp info find Python using Python version 3.9.4 found at &quot;C:\Users\ahboy\AppData\Local\Programs\Python\Python39\python.exe&quot;
  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 unknown version &quot;undefined&quot; found at &quot;C:\Program Files\Microsoft Visual Studio\2022\Professional&quot;
  npm ERR! gyp ERR! find VS could not find a version of Visual Studio 2017 or newer to use
  npm ERR! gyp ERR! find VS looking for Visual Studio 2015
  npm ERR! gyp ERR! find VS - not found
  </code></pre>
  <p><a href="https://i.stack.imgur.com/7ZKHD.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/7ZKHD.png" alt="error" /></a></p>
  <p>I went to do some research and found out that node-gyp@8.3.0 does not support VS 2022. Only version node-gyp@8.4 does. So I started to try to get npm to use node-gyp@8.4.0 but nothing works including this advice from node-gyp <a href="https://github.com/nodejs/node-gyp/issues/2272" rel="nofollow noreferrer">github page</a> to install node-gyp globally and point the path in npmrc file.</p>
  <p>So what can be done to force npm to use different node-gyp versions when installing packages?</p>