Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gyp: Undefined variable module_name in binding.gyp while trying to load binding.gyp #1434

Closed
KotoriK opened this issue Jan 26, 2021 · 10 comments

Comments

@KotoriK
Copy link

KotoriK commented Jan 26, 2021

Environment:

  • Linux 5.0.11-1.el7.elrepo.x86_64
  • node v15.6.0
  • node-gyp v7.1.2 (installed globally)
  • Python version 2.7.5

Full Log

$ node-gyp rebuild
gyp info it worked if it ends with ok
gyp info using [email protected]
gyp info using [email protected] | linux | x64
gyp info find Python using Python version 2.7.5 found at "/usr/bin/python"
gyp info spawn /usr/bin/python
gyp info spawn args [
gyp info spawn args   '/usr/local/lib/node_modules/node-gyp/gyp/gyp_main.py',
gyp info spawn args   'binding.gyp',
gyp info spawn args   '-f',
gyp info spawn args   'make',
gyp info spawn args   '-I',
gyp info spawn args   '**project_directory**/node_modules/sqlite3/build/config.gypi',
gyp info spawn args   '-I',
gyp info spawn args   '/usr/local/lib/node_modules/node-gyp/addon.gypi',
gyp info spawn args   '-I',
gyp info spawn args   '**user_root**/.cache/node-gyp/15.6.0/include/node/common.gypi',
gyp info spawn args   '-Dlibrary=shared_library',
gyp info spawn args   '-Dvisibility=default',
gyp info spawn args   '-Dnode_root_dir=**user_root**/.cache/node-gyp/15.6.0',
gyp info spawn args   '-Dnode_gyp_dir=/usr/local/lib/node_modules/node-gyp',
gyp info spawn args   '-Dnode_lib_file=**user_root**/.cache/node-gyp/15.6.0/<(target_arch)/node.lib',
gyp info spawn args   '-Dmodule_root_dir=**project_directory**/node_modules/sqlite3',
gyp info spawn args   '-Dnode_engine=v8',
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 info spawn args ]
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:351:16)
gyp ERR! stack     at ChildProcess.emit (node:events:379:20)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (node:internal/child_process:285:12)
gyp ERR! System Linux 5.0.11-1.el7.elrepo.x86_64
gyp ERR! command "/usr/local/bin/node" "/usr/local/bin/node-gyp" "rebuild"
gyp ERR! cwd **project_directory**/node_modules/sqlite3
gyp ERR! node -v v15.6.0
gyp ERR! node-gyp -v v7.1.2
gyp ERR! not ok 

seem like the same problem with #851 #766

@KotoriK
Copy link
Author

KotoriK commented Jan 26, 2021

FINALLY SOLVED.
For my environment, manually add module_name= and module_path=***your_project_root/node_modules/sqlite3/lib/binding/node-v88-linux-x64after node-gyp rebuild , wait for building, and then the project can properly find sqlite module.
So why nobody reply on any of these same issues? That could save people lives.

@cyrilfr
Copy link

cyrilfr commented Feb 4, 2021

Hi @KotoriK , how did you manage to manually add module_name and module_path? Where do you set those parameters? Thanks. I'm having the same issue on Ubuntu 20.04 with Node.js v10.19.0, sqlite3 v4.2.0 and node-gyp v6.1.0.

@KotoriK
Copy link
Author

KotoriK commented Feb 7, 2021

Hi @KotoriK , how did you manage to manually add module_name and module_path? Where do you set those parameters? Thanks. I'm having the same issue on Ubuntu 20.04 with Node.js v10.19.0, sqlite3 v4.2.0 and node-gyp v6.1.0.

add as arguments after "node-gyp rebuild". like "node-gyp rebuild --module-name=balabala"

@joao-paulo-parity
Copy link

joao-paulo-parity commented Feb 22, 2021

I was having this issue on CI. The problem is that one of this package's lifecycle scripts (more specifically, install or postinstall) are not behaving correctly.

install is defined here; in order to install node_modules without triggering it (might be situationally sub-optimal since you're ignoring all scripts, thus something else might break)

npm {ci,install} --ignore-scripts

Then compile from source (mentioned here)

cd ./node_modules/sqlite3 && npm install --build-from-source

Note: build-from-source is a feature of node-pre-gyp.


Now, I've noticed this is not as good as a workaround for local development - ideally you'd want to have npm install "just work". I'm afraid that, being a lifecycle script, it might not be solvable without patching the package, but I have yet to confirm this.

@joao-paulo-parity
Copy link

I'm noticing I'm not having the installation issue described above if I upgrade to 5.0.2. Might be related to 0eba2cd.

@kewde pinging since you authored those changes. Please check out #1434 (comment) and #1441 when you have the time. As it currently is, for those on 5.0.1, the "workaround" I mentioned of using --ignore-scripts is sub-optimal because it might break other packages unintentionally.

@KotoriK
Copy link
Author

KotoriK commented Feb 24, 2021

I've tried [email protected] on the same environment and it threw the same error.
After rechecked package.json, I found it seems like a node-pre-gyp issue. According to the manual, if functions normally, node-pre-gyp should read and apply those variables from binary in package.json, however it doesn't.
I used the latest @mapbox/node-pre-gyp(installed globally) for the above test.

@kewde
Copy link
Collaborator

kewde commented Mar 10, 2021

Thank you for submitting this issue, it's greatly appreciated.

I've merged pull requests that may impact this, please clone master and check again.
Ping me if the issue persists - I can not replicate it however.

@KotoriK
Copy link
Author

KotoriK commented Mar 11, 2021

Thank you for submitting this issue, it's greatly appreciated.

I've merged pull requests that may impact this, please clone master and check again.
Ping me if the issue persists - I can not replicate it however.

It works. Thanks.

@KotoriK KotoriK closed this as completed Mar 11, 2021
@migralito
Copy link

what is supposed to be the module name??

@Solpapaya
Copy link

@migralito the module_name and module_path is inside the package.json of the module you want to install

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants