41

I have been working on this all day and have tried lots of different things:

  • Uninstalling node and installing latest version
  • Using the --msvs_version= flag set to 2010, 2011, 2012, 2013, 2015
  • Deleting the .node-gyp folder
  • Adding python path to .npmrc like so: python=C:\Python27\python.exe
  • npm -g install npm@next
  • Running node-gyp rebuild and node-gyp configure
  • Following Robert Kehoe's guide

Rough times.

The package is an Electron/React app and I am running Windows 10. Console output for npm install is

C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\Platforms\x64\Microsoft.Cpp.x64.Targets(514,5): error MSB8008: Specif
ied platform toolset (v120) is not installed or invalid. Please make sure that a supported PlatformToolset value is sel
ected. [C:\Users\scheinerbock\Desktop\mpstudio\node_modules\mplib\build\addon.vcxproj]
gyp ERR! build error
gyp ERR! stack Error: `msbuild` failed with exit code: 1
gyp ERR! stack     at ChildProcess.onExit (C:\Users\scheinerbock\AppData\Roaming\npm\node_modules\npm\node_modules\node-gyp\lib\build.js:276:23)
gyp ERR! stack     at emitTwo (events.js:106:13)
gyp ERR! stack     at ChildProcess.emit (events.js:191:7)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:215:12)
gyp ERR! System Windows_NT 10.0.14393
gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "C:\\Users\\scheinerbock\\AppData\\Roaming\\npm\\node_modules\\npm\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild"
gyp ERR! cwd C:\Users\scheinerbock\Desktop\mpstudio\node_modules\mplib
gyp ERR! node -v v6.10.0
gyp ERR! node-gyp -v v3.5.0
gyp ERR! not ok

And for node-gyp rebuild:

gyp: binding.gyp not found (cwd: C:\Users\scheinerbock\Desktop\mpstudio) while trying to load binding.gyp

I am well out of my wheelhouse here and would appreciate any suggestions or information in addition to solutions.

Ben S
  • 778
  • 1
  • 5
  • 19
  • 1
    Hello Ben, can you eloborate how you solved it, exact steps for a newer machine? which node version, npm version, whats exact commands did you run to succeed it ? Thanks – TyForHelpDude Oct 19 '18 at 08:05
  • @TyForHelpDude I no longer work on this project anymore, and I don't even have the computer I got things running on. So unfortunately I don't have a way of getting that info for you. Sorry – Ben S Oct 21 '18 at 22:10

7 Answers7

29

I am using macos catalina 10.15.5 and i faced the same issues and all the above solutions didn't worked for me. I was able to resolve this by running

npm i -g node-gyp@latest && npm config set node_gyp "/usr/local/lib/node_modules/node-gyp/bin/node-gyp.js"

Hope this helps people.

akmozo
  • 9,829
  • 3
  • 28
  • 44
Zaid Haider
  • 530
  • 6
  • 11
  • 5
    Worked like a charm. Mind you... one should use the path node_gyp as determined by one's specific environment. my `node-gyp.js` was installed at `~/.nvm/versions/node/v6.17.1/lib/node_modules/node-gyp/bin/node-gyp.js` – Kagiso Marvin Molekwa Oct 27 '21 at 10:11
  • 1
    fyi for others: this is fully documented [here](https://github.com/nodejs/node-gyp/blob/master/macOS_Catalina.md) – sam-6174 Jun 07 '22 at 18:11
14

create a binding.gyp file and place it in your project root. the content of the file looks like this:

{
  "targets": [
    {
      "target_name": "binding",
      "sources": [ "src/binding.cc" ]
    }
  ]
}

A binding.gyp file describes the configuration to build your module, in a JSON-like format. This file gets placed in the root of your package, alongside package.json. see here: https://github.com/nodejs/node-gyp#the-bindinggyp-file

Reagan Ochora
  • 1,642
  • 1
  • 19
  • 22
  • This had no effect for me on macOS High Sierra – Madbreaks Sep 14 '21 at 18:51
  • 3
    The solution here worked after that of @Zaid Haider (https://stackoverflow.com/a/62108079/777885) on macOS Big Sur. FYI binding.cc can just be an empty file – Jono Dec 28 '21 at 17:37
  • I ran npm i -g node-gyp then followed along above answer and then ran node-gyp configure works without the hassle of path. – Sarath Jun 16 '23 at 10:59
2

Make sure that you have python 2.x version installed & not 3.x For me it worked after i installed python 2.6

user1416932
  • 257
  • 3
  • 6
1

See this thread, maybe it helps.

node-gyp uses Visual Studio for building on Windows, so I guess the issue comes from your VS installation.

Judging from this path (C:\Program Files (x86)\MSBuild), looks like it requires a newer version (perhaps Visual Studio 2015 where MSBuild was first introduced).

mihai
  • 37,072
  • 9
  • 60
  • 86
  • Thank you for the answer mihai. Unfortunately I did install VS2015, and I tried many other versions as well. I wound up giving up on building the project on the old computer I was using and succeeded in building on a newer machine. – Ben S Mar 17 '17 at 23:30
1

Try downgrade npm version to v6:

npm install -g npm@6 

or downgrade node version to v12 together use nvm

Ref: https://github.com/nodejs/node-gyp/issues/508

Junior Tour
  • 439
  • 7
  • 8
0

Had tried so many solutions, this one seemed to work instantly for me. Install g++ and cmake, with command 'apt install make g++', for windows I believe these have thier website for downloading.

https://cmake.org/download/ - for make | https://sourceware.org/cygwin/ - for g++ (If not search gcc on google)

I haven't tested this for windows, this worked for me with the apt command on Linux.

Libby Lebyane
  • 167
  • 2
  • 14
0

If you are using NVM on Windows here's what you can do:

Create the following file at your HOME User -> binding.gyp

  • example: c:/users/my-user/binding.gyp

Then this will be the content (in this case my node version is 14.21.2, but you can replace it with your current version.)

{
    "targets": [{
        "target_name": "binding",
        "sources": [ "C:/ProgramData/nvm/v14.21.2" ]
    }]
}
jonathanlima
  • 159
  • 2
  • 9