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.
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:[email protected] [email protected] install: `node-gyp rebuild`
npm WARN install:[email protected] Exit status 1
[email protected] install C:\Users\user\DemoApp2\node_modules\utf-8-validate
node-gyp rebuild
So i followed below steps to fix the issue :
npm config set msvs_version 2013 --global as suggested by
catalint..npm-gyp under C:\Users\usernpm install -g fs --save-devC:\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)npm install --msvs_version=2013 node-gyp rebuild After doing above steps i stopped getting build errors.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With