Home > other >  node gyp says build tools are undefined
node gyp says build tools are undefined

Time:08-21

I have installed the latest Visual Studio Build tools 2022 using these instructions: enter image description here

This is my .npmrc file:

msvs_version=2017
msbuild_path=C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\MSBuild\Current\Bin\MSBuild.exe

Following the path to my build tools: enter image description here

Following the MSBuild.exe I run this file and get:

C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\MSBuild\Current\Bin\MSBuild.exe enter image description here

The error message when trying to install a package I get is:

npm install enter image description here

Now it gets interesting: running gyp configure I don't get the same error:

enter image description here

I wonder what else can I do? I went trough countless threads and couldn't resolve this issue. I have a machine with windows 10 on, and did the exact same procedure and it works. But here, the path to the build tools can't be found.

CodePudding user response:

According to your screenshot you are using node-gyp 5.1.0, not 9.1.0, which is three years old at this point. So it not finding Visual Studio 2022, which was released last year, isn't unexpected.

You need to update your node-gyp version (or node, since node v14 is also old). If you update to a new version of node the installer will ask you if you want to install the build tools as well which is usually a good idea.

If you however want to upgrade your current node-gyp you can follow these steps, assuming node is installed in C:\Program Files\nodejs\ (taken from the node-gyp docs)

cd "C:\Program Files\nodejs\node_modules\npm\node_modules\@npmcli\run-script"
npm install node-gyp@latest
  • Related