13

Hello I am on the processes of creating a native node module on windows, but whenever I ran the node-gyp build binding.gyp command I obtain an error that states "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 that to the PATH variable, and I am able to start a cmd prompt and run msbuild.exe and it will return the version so that seems to be working, but for some reason node-gyp cannot detect it, I even attempted to modify the build.js file within node-gyp to have it point to the msbuild location but it fails.

Alan
  • 1,134
  • 2
  • 13
  • 25

4 Answers4

8

In my case it was giving below error :

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 below steps to fix the issue :

  1. Firstly 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.
  2. Delete the folder .npm-gyp under C:\Users\user
  3. execute npm install -g fs --save-dev
  4. 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 its C:\Program Files\nodejs\node_modules\npm\node_modules)
  5. execute npm install --msvs_version=2013 node-gyp rebuild

After doing above steps i stopped getting build errors.

Alex M
  • 2,756
  • 7
  • 29
  • 35
decay
  • 81
  • 1
  • 4
7

I used multiple fixes to try and get this resolved. My versions are: 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 received the same error. Using

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

seems to work consistently.

I hope this helps someone as I've seen lots of problems trying to get this working in windows.

James Drinkard
  • 15,342
  • 16
  • 114
  • 137
1

For me, the solution was to run this at an admin command prompt:

npm install --global --production windows-build-tools

This actually got stuck and didn't finish gracefully, but I was able to close it using Ctrl-C. After that npm install was able to get past node-gyp and finished without errors.

OutstandingBill
  • 2,614
  • 26
  • 38
0

You can download just the build tools

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

run cmd to set global flag to use the 2013 version:

npm config set msvs_version 2013 --global

after this everything should be back to normal and your npm install / node-gyp rebuild will work

catalint
  • 1,895
  • 17
  • 17