node-gyp: gyp: Undefined variable module_name in binding.gyp while trying to load binding.gyp

I’m trying to use meteor-up to deploy my app from OSX to a Ubuntu 14.04 x64 system, but it’s throwing an error gyp: Undefined variable module_name in binding.gyp while trying to load binding.gyp as seen below.

We think that <module_name> gyp variable should be available in node 0.10.x, but somehow it’s still causing the error.

How can we define <(module_name)? Is that the problem?

$ mup deploy

Meteor Up: Production Quality Meteor Deployments
------------------------------------------------

Bundling Started: .

Started TaskList: Deploy app 'my-test-app' (linux)
[192.168.1.114] - Uploading bundle
[192.168.1.114] ✔ Uploading bundle: SUCCESS
[192.168.1.114] - Setting up Environment Variables
[192.168.1.114] ✔ Setting up Environment Variables: SUCCESS
[192.168.1.114] - Invoking deployment process
[192.168.1.114] ✘ Invoking deployment process: FAILED

    -----------------------------------STDERR-----------------------------------
    gyp info spawn args   '-Dmodule_root_dir=/opt/my-test-app/tmp/bundle/programs/server/npm/npm-container/node_modules/serialport',
    gyp info spawn args   '--depth=.',
    gyp info spawn args   '--no-parallel',
    gyp info spawn args   '--generator-output',
    gyp info spawn args   'build',
    gyp info spawn args   '-Goutput_dir=.' ]
    gyp: Undefined variable module_name in binding.gyp while trying to load binding.gyp
    gyp ERR! configure error 
    gyp ERR! stack Error: `gyp` failed with exit code: 1
    gyp ERR! stack     at ChildProcess.onCpExit (/usr/local/lib/node_modules/node-gyp/lib/configure.js:343:16)
    gyp ERR! stack     at ChildProcess.emit (events.js:98:17)
    gyp ERR! stack     at Process.ChildProcess._handle.onexit (child_process.js:810:12)
    gyp ERR! System Linux 3.12.28+
    gyp ERR! command "node" "/usr/local/bin/node-gyp" "rebuild"
    gyp ERR! cwd /opt/my-test-app/tmp/bundle/programs/server/npm/npm-container/node_modules/serialport
    gyp ERR! node -v v0.10.32
    gyp ERR! node-gyp -v v1.0.2
    gyp ERR! not ok 
    -----------------------------------STDOUT-----------------------------------
    => re-installing binary npm module 'serialport' of package 'npm-container'
    ----------------------------------------------------------------------------
Completed TaskList: Deploy app 'my-test-app' (linux)

bindings.gyp

{
  'targets': [
    {
      'target_name': 'serialport',
      'sources': [
        'src/serialport.cpp',
      ],
      'include_dirs': [
        '<!(node -e "require(\'nan\')")'
      ],
      'conditions': [
        ['OS=="win"',
          {
            'sources': [
              'src/serialport_win.cpp',
              'src/win/disphelper.c',
              'src/win/enumser.cpp',
            ],
            'msvs_settings': {
              'VCCLCompilerTool': {
                'ExceptionHandling': '2',
                'DisableSpecificWarnings': [ '4530', '4506' ],
              },
            },
          },
        ],
        ['OS=="mac"',
          {
            'sources': [
              'src/serialport_unix.cpp',
              'src/serialport_poller.cpp',
            ],
            'xcode_settings': {
              'OTHER_LDFLAGS': [
                '-framework CoreFoundation -framework IOKit'
              ]
            }
          }
        ],
        ['OS!="win"',
          {
            'sources': [
              'src/serialport_unix.cpp',
              'src/serialport_poller.cpp',
            ],
          }
        ],
      ],
    },
    {
      "target_name": "action_after_build",
      "type": "none",
      "dependencies": [ "<(module_name)" ],
      "copies": [
        {
          "files": [ "<(PRODUCT_DIR)/<(module_name).node" ],
          "destination": "<(module_path)"
        }
      ]
    }
  ],
}

About this issue

  • Original URL
  • State: closed
  • Created 10 years ago
  • Reactions: 3
  • Comments: 24 (5 by maintainers)

Most upvoted comments

same, it happen when I install electron-forge. I fix it by npm install -g npm@6, it seems somethings wrong with npm@7

Do a npm update and npm install after. Worked for me.

I did a

npm i node-pre-gyp rebuild

And it worked

For me, dropping from Node v15 down to Node v14 did the trick.

same rror for me

npm install -g npm@6

For anyone looking for a quick fix, this worked for me. There seems to be a dep issue with NPM 7.

Same here, the package definitely has a problem with npm 7.x

same, there seems a problem with this feature and NodeV15. Dropping to 14 fixed it for me too. NVM recommended.

+1 Sqlite3 Undefined variable module_name in binding.gyp while trying to load binding.gyp

@springmeyer I am experiencing the same error when I try to compile sqlite3 against electron.

node-gyp rebuild --target=0.30.2 --arch=x32 --target_platform=win32 --dist-url=https://atom.io/download/atom-shell


gyp: Undefined variable module_name in binding.gyp while trying to load binding.gyp
gyp ERR! configure error
gyp ERR! stack Error: `gyp` failed with exit code: 1
gyp ERR! stack     at ChildProcess.onCpExit (C:\Users\Stephan\AppData\Roaming\npm\node_modules\node-gyp\lib\configure.js:357:16)
gyp ERR! stack     at ChildProcess.emit (events.js:110:17)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (child_process.js:1074:12)
gyp ERR! System Windows_NT 6.3.9600
gyp ERR! command "node" "C:\\Users\\Stephan\\AppData\\Roaming\\npm\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild" "--target=0.30.2" "--arch=x32" "--target_platform=win32" "--dist-url=https://atom.io/download/atom-shell"
gyp ERR! cwd C:\git\electron-dev-tools-extension-test\node_modules\sqlite3
gyp ERR! node -v v0.12.6
gyp ERR! node-gyp -v v2.0.2
gyp ERR! not ok

Any workaround I can try out`?

Oh, I see the problem, it is meteor-up, instead of sudo node-gyp rebuild right here it needs to be npm install which will dispatch to node-pre-gyp rebuild: https://github.com/voodootikigod/node-serialport/blob/62bae007a4edadad3c1f6760bf056a1556119869/package.json#L72