Search code examples
node.jsnode-gyp

node-gyp: "..\src\binding.cc: no such file or directory"


I have stumbled upon "..\src\binding.cc: no such file or directory" when building an Electron app with electron-builder. Log:

⨯ node-gyp.cmd exited with code ERR_ELECTRON_BUILDER_CANNOT_EXECUTE
Output:
Warning: Missing input files:
C:\Users\%user%\source\repos\electronvueapp\build\..\src\binding.cc
�믮������ ��᫥����⥫쭠� ᡮઠ �஥�⮢ � �⮬ �襭��. �⮡� ������� ��ࠫ������ ᡮ��, ������� ��ࠬ��� "-m".
  binding.cc
c1xx : fatal error C1083: �� 㤠���� ������ 䠩� ���筨�: ..\src\binding.cc: No such file or directory, [C:\Users\%user%\source\repos\electronvueapp\build\binding.vcxproj]

Googling mostly gave me results alike referenced here: "node-gyp build" Fatal error C1083

The common solution is to just create an empty "binding.cc" at the path, but my problem is that every time I try to build the app it just removes the "build" folder and makes a new one, but without the "binding.cc" in it


Solution

  • Build and bin folders will be delete every install. You can change the build folder name anything else. Sample directory:

    -dir_of_cc
        -binding.cc
    -binding.gyp
    

    Binding attribute object in binding.gyp file:

    {
        "target_name": "binding-name",
        "cflags!": [ "-fno-exceptions" ],
        "cflags_cc!": [ "-fno-exceptions" ],
        "sources": ["dir_of_cc\binding.cc"],
        'include_dirs': [
            "<!@(node -p \"require('node-addon-api').include\")"
        ],
        'libraries': [],
        'dependencies': [
            "<!(node -p \"require('node-addon-api').gyp\")"
        ],
        'defines': [ 'NAPI_DISABLE_CPP_EXCEPTIONS' ]
    }