Node -gyp cannot find msbuild.exe

Hello, I am in the process of creating a native node module on Windows, but whenever I run the node-gyp build binding.gyp , I get an error that indicates "error: Can't find "msbuild.exe". Do you have Microsoft Visual Studio C++ 2008 installed?" . I have Visual Studio 2013 installed and the msbuild directory is C:\Windows\Microsoft.NET\Framework\v3.5\msbuild.exe. I tried adding this to the PATH variable and I can run the cmd prompt and run msbuild.exe and it will return the version for it to work, but for some reason node -gyp cannot detect it, I even tried to modify the build file. js in node -gyp so that it points to the msbuild location, but it fails.

+6
source share
3 answers

You can only download build tools

Microsoft Build Tools 2013: http://www.microsoft.com/en-us/download/details.aspx?id=40760

run cmd to set the global flag for using version 2013:

npm config set msvs_version 2013 --global

after that, everything should return to normal operation, and your npm install / node -gyp rebuild will work

+2
source

I used several fixes to try to solve this problem. My versions: Nodejs 0.12.4 (64 bit), Git 2.5.3, npm 2.10.1, Windows 7 and Visual Studio 2013. Nothing worked until I tried this command:

 npm install -g node-gyp 

However, the next time I tried to do this, I got the same error. Using

 npm install -g --msvs_version=2013 node-gyp rebuild 

seems to work sequentially.

I hope this helps someone as I saw a lot of problems trying to get this to work in windows.

+2
source

In my case, this led to the error below:

 C:\Users\user\DemoApp2\node_modules\bufferutil>if not defined npm_config_node_gyp (node "C:\Program Files\nodejs\node_modules\npm\bin\node-gyp-bin\\..\..\node_modules\node-gyp\bin\node-gyp.js" rebuild ) else (node "" rebuild ) gyp ERR! build error gyp ERR! stack Error: Can't find "msbuild.exe". Do you have Microsoft Visual Studio C++ 2008+ installed? gyp ERR! stack at findMsbuild (C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\lib\build.js:128:23) gyp ERR! stack at C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\lib\build.js:110:11 gyp ERR! stack at F (C:\Program Files\nodejs\node_modules\npm\node_modules\which\which.js:69:16) gyp ERR! stack at E (C:\Program Files\nodejs\node_modules\npm\node_modules\which\which.js:81:29) gyp ERR! stack at C:\Program Files\nodejs\node_modules\npm\node_modules\which\which.js:90:16 gyp ERR! stack at C:\Program Files\nodejs\node_modules\npm\node_modules\which\node_modules\isexe\index.js:44:5 gyp ERR! stack at C:\Program Files\nodejs\node_modules\npm\node_modules\which\node_modules\isexe\windows.js:29:5 gyp ERR! stack at FSReqWrap.oncomplete (fs.js:123:15) gyp ERR! System Windows_NT 10.0.10240 gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild" gyp ERR! cwd C:\Users\user\DemoApp2\node_modules\bufferutil gyp ERR! node -v v6.3.1 gyp ERR! node-gyp -v v3.3.1 gyp ERR! not ok npm WARN install: bufferutil@1.2.1 bufferutil@1.2.1 install: `node-gyp rebuild` npm WARN install: bufferutil@1.2.1 Exit status 1 utf-8-validate@1.2.1 install C:\Users\user\DemoApp2\node_modules\utf-8-validate node-gyp rebuild 

So, I followed these steps to fix the problem:

  • First download and install Microsoft Build Tools 2013 from:
    http://www.microsoft.com/en-us/download/details.aspx?id=40760 and run npm config set msvs_version 2013 --global , as suggested by catalint.
  • Delete the .npm-gyp under C:\Users\user
  • run npm install -g fs --save-dev
  • Copy the downloaded fs folder from C:\Users\user\AppData\Roaming\npm\node_modules to $nodehome\node_modules\npm\node_modules (Note: in my case it is C:\Program Files\nodejs\node_modules\npm\node_modules )
  • run npm install --msvs_version=2013 node-gyp rebuild

After completing the above steps, I stopped getting build errors.

+2
source

Source: https://habr.com/ru/post/981846/


All Articles