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 #86

Open
kalashnikov2 opened this issue Nov 22, 2021 · 4 comments

Comments

@kalashnikov2
Copy link

failed to install

sudo npm install -g lightning-charge --unsafe-perm

npm ERR! code 1
npm ERR! path /usr/local/lib/nodejs/node-v14.17.6-linux-arm64/lib/node_modules/lightning-charge/node_modules/sqlite3
npm ERR! command failed
npm ERR! command sh -c node-gyp rebuild
npm ERR! gyp info it worked if it ends with ok
npm ERR! gyp info using node-gyp@8.4.0
npm ERR! gyp info using node@14.17.6 | linux | arm64
npm ERR! gyp info find Python using Python version 3.7.3 found at "/usr/bin/python3"
npm ERR! gyp WARN EACCES current user ("pi") does not have permission to access the dev dir "/root/.cache/node-gyp/14.17.6"
npm ERR! gyp WARN EACCES attempting to reinstall using temporary dev dir "/tmp/.node-gyp"
npm ERR! gyp info spawn /usr/bin/python3
npm ERR! gyp info spawn args [
npm ERR! gyp info spawn args '/usr/local/lib/nodejs/node-v14.17.6-linux-arm64/lib/node_modules/npm/node_modules/node-gyp/gyp/gyp_main.py',
npm ERR! gyp info spawn args 'binding.gyp',
npm ERR! gyp info spawn args '-f',
npm ERR! gyp info spawn args 'make',
npm ERR! gyp info spawn args '-I',
npm ERR! gyp info spawn args '/usr/local/lib/nodejs/node-v14.17.6-linux-arm64/lib/node_modules/lightning-charge/node_modules/sqlite3/build/config.gypi',
npm ERR! gyp info spawn args '-I',
npm ERR! gyp info spawn args '/usr/local/lib/nodejs/node-v14.17.6-linux-arm64/lib/node_modules/npm/node_modules/node-gyp/addon.gypi',
npm ERR! gyp info spawn args '-I',
npm ERR! gyp info spawn args '/tmp/.node-gyp/14.17.6/include/node/common.gypi',
npm ERR! gyp info spawn args '-Dlibrary=shared_library',
npm ERR! gyp info spawn args '-Dvisibility=default',
npm ERR! gyp info spawn args '-Dnode_root_dir=/tmp/.node-gyp/14.17.6',
npm ERR! gyp info spawn args '-Dnode_gyp_dir=/usr/local/lib/nodejs/node-v14.17.6-linux-arm64/lib/node_modules/npm/node_modules/node-gyp',
npm ERR! gyp info spawn args '-Dnode_lib_file=/tmp/.node-gyp/14.17.6/<(target_arch)/node.lib',
npm ERR! gyp info spawn args '-Dmodule_root_dir=/usr/local/lib/nodejs/node-v14.17.6-linux-arm64/lib/node_modules/lightning-charge/node_modules/sqlite3',
npm ERR! gyp info spawn args '-Dnode_engine=v8',
npm ERR! gyp info spawn args '--depth=.',
npm ERR! gyp info spawn args '--no-parallel',
npm ERR! gyp info spawn args '--generator-output',
npm ERR! gyp info spawn args 'build',
npm ERR! gyp info spawn args '-Goutput_dir=.'
npm ERR! gyp info spawn args ]
npm ERR! gyp: Undefined variable module_name in binding.gyp while trying to load binding.gyp
npm ERR! gyp ERR! configure error
npm ERR! gyp ERR! stack Error: gyp failed with exit code: 1
npm ERR! gyp ERR! stack at ChildProcess.onCpExit (/usr/local/lib/nodejs/node-v14.17.6-linux-arm64/lib/node_modules/npm/node_modules/node-gyp/lib/configure.js:259:16)
npm ERR! gyp ERR! stack at ChildProcess.emit (events.js:400:28)
npm ERR! gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:277:12)
npm ERR! gyp ERR! System Linux 5.10.63-v8+
npm ERR! gyp ERR! command "/usr/local/lib/nodejs/node-v14.17.6-linux-arm64/bin/node" "/usr/local/lib/nodejs/node-v14.17.6-linux-arm64/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
npm ERR! gyp ERR! cwd /usr/local/lib/nodejs/node-v14.17.6-linux-arm64/lib/node_modules/lightning-charge/node_modules/sqlite3
npm ERR! gyp ERR! node -v v14.17.6
npm ERR! gyp ERR! node-gyp -v v8.4.0
npm ERR! gyp ERR! not ok

@kalashnikov2
Copy link
Author

full log on -verbose

npm info run sqlite3@5.0.2 install node_modules/lightning-charge/node_modules/sqlite3 node-gyp rebuild
npm info run sqlite3@5.0.2 install { code: 1, signal: null }
npm timing reify:rollback:createSparse Completed in 7398ms
npm timing reify:rollback:retireShallow Completed in 0ms
npm timing command:install Completed in 128667ms
npm verb stack Error: command failed
npm verb stack at ChildProcess. (/usr/share/nodejs/@npmcli/promise-spawn/index.js:64:27)
npm verb stack at ChildProcess.emit (events.js:314:20)
npm verb stack at maybeClose (internal/child_process.js:1022:16)
npm verb stack at Socket. (internal/child_process.js:444:11)
npm verb stack at Socket.emit (events.js:314:20)
npm verb stack at Pipe. (net.js:676:12)
npm verb pkgid sqlite3@5.0.2
npm verb cwd /home/pi
npm verb Linux 5.10.63-v7+
npm verb argv "/usr/bin/node" "/usr/bin/npm" "install" "-g" "lightning-charge" "--verbose"
npm verb node v12.22.5
npm verb npm v7.5.2
npm ERR! code 1
npm ERR! path /usr/local/lib/node_modules/lightning-charge/node_modules/sqlite3
npm ERR! command failed
npm ERR! command sh -c node-gyp rebuild
npm ERR! gyp info it worked if it ends with ok
npm ERR! gyp verb cli [
npm ERR! gyp verb cli '/usr/bin/node',
npm ERR! gyp verb cli '/usr/share/nodejs/node-gyp/bin/node-gyp.js',
npm ERR! gyp verb cli 'rebuild'
npm ERR! gyp verb cli ]
npm ERR! gyp info using node-gyp@7.1.2
npm ERR! gyp info using node@12.22.5 | linux | arm
npm ERR! gyp verb command rebuild []
npm ERR! gyp verb command clean []
npm ERR! gyp verb clean removing "build" directory
npm ERR! gyp verb command configure []
npm ERR! gyp verb find Python Python is not set from command line or npm configuration
npm ERR! gyp verb find Python Python is not set from environment variable PYTHON
npm ERR! gyp verb find Python checking if "python3" can be used
npm ERR! gyp verb find Python - executing "python3" to get executable path
npm ERR! gyp verb find Python - executable path is "/usr/bin/python3"
npm ERR! gyp verb find Python - executing "/usr/bin/python3" to get version
npm ERR! gyp verb find Python - version is "3.9.2"
npm ERR! gyp info find Python using Python version 3.9.2 found at "/usr/bin/python3"
npm ERR! gyp verb get node dir no --target version specified, falling back to host node version: 12.22.5
npm ERR! gyp verb build dir attempting to create "build" dir: /usr/local/lib/node_modules/lightning-charge/node_modules/sqlite3/build
npm ERR! gyp verb build dir "build" dir needed to be created? /usr/local/lib/node_modules/lightning-charge/node_modules/sqlite3/build
npm ERR! gyp verb build/config.gypi creating config file
npm ERR! gyp verb build/config.gypi writing out config file: /usr/local/lib/node_modules/lightning-charge/node_modules/sqlite3/build/config.gypi
npm ERR! gyp verb config.gypi checking for gypi file: /usr/local/lib/node_modules/lightning-charge/node_modules/sqlite3/config.gypi
npm ERR! gyp verb common.gypi checking for gypi file: /usr/local/lib/node_modules/lightning-charge/node_modules/sqlite3/common.gypi
npm ERR! gyp verb gyp gyp format was not specified; forcing "make"
npm ERR! gyp info spawn /usr/bin/python3
npm ERR! gyp info spawn args [
npm ERR! gyp info spawn args '/usr/share/nodejs/node-gyp/gyp/gyp_main.py',
npm ERR! gyp info spawn args 'binding.gyp',
npm ERR! gyp info spawn args '-f',
npm ERR! gyp info spawn args 'make',
npm ERR! gyp info spawn args '-I',
npm ERR! gyp info spawn args '/usr/local/lib/node_modules/lightning-charge/node_modules/sqlite3/build/config.gypi',
npm ERR! gyp info spawn args '-I',
npm ERR! gyp info spawn args '/usr/share/nodejs/node-gyp/addon.gypi',
npm ERR! gyp info spawn args '-I',
npm ERR! gyp info spawn args '/usr/include/nodejs/common.gypi',
npm ERR! gyp info spawn args '-Dlibrary=shared_library',
npm ERR! gyp info spawn args '-Dvisibility=default',
npm ERR! gyp info spawn args '-Dnode_root_dir=/usr/include/nodejs',
npm ERR! gyp info spawn args '-Dnode_gyp_dir=/usr/share/nodejs/node-gyp',
npm ERR! gyp info spawn args '-Dnode_lib_file=/usr/include/nodejs/<(target_arch)/node.lib',
npm ERR! gyp info spawn args '-Dmodule_root_dir=/usr/local/lib/node_modules/lightning-charge/node_modules/sqlite3',
npm ERR! gyp info spawn args '-Dnode_engine=v8',
npm ERR! gyp info spawn args '--depth=.',
npm ERR! gyp info spawn args '--no-parallel',
npm ERR! gyp info spawn args '--generator-output',
npm ERR! gyp info spawn args 'build',
npm ERR! gyp info spawn args '-Goutput_dir=.'
npm ERR! gyp info spawn args ]
npm ERR! gyp: Undefined variable module_name in binding.gyp while trying to load binding.gyp
npm ERR! gyp ERR! configure error
npm ERR! gyp ERR! stack Error: gyp failed with exit code: 1
npm ERR! gyp ERR! stack at ChildProcess.onCpExit (/usr/share/nodejs/node-gyp/lib/configure.js:355:16)
npm ERR! gyp ERR! stack at ChildProcess.emit (events.js:314:20)
npm ERR! gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:276:12)
npm ERR! gyp ERR! System Linux 5.10.63-v7+
npm ERR! gyp ERR! command "/usr/bin/node" "/usr/share/nodejs/node-gyp/bin/node-gyp.js" "rebuild"
npm ERR! gyp ERR! cwd /usr/local/lib/node_modules/lightning-charge/node_modules/sqlite3
npm ERR! gyp ERR! node -v v12.22.5
npm ERR! gyp ERR! node-gyp -v v7.1.2
npm ERR! gyp ERR! not ok
npm verb exit 1
npm timing npm Completed in 130453ms

@shesek
Copy link
Contributor

shesek commented Jan 30, 2022

I suggest following these instructions to install global packages as a non-root user, so that you don't need to install with sudo and don't need the --unsafe-perm option:

https://docs.npmjs.com/resolving-eacces-permissions-errors-when-installing-packages-globally#manually-change-npms-default-directory

(also mentioned in the readme)

Let me know if you're still having trouble.

@freerko
Copy link

freerko commented Feb 15, 2022

Hi @shesek, trying to install lightning-charge fails for me as well with the "gyp: Undefined variable module_name in binding.gyp while trying to load binding.gyp" error (but no explicit permission denied errors). I am on Ubuntu 20.04, npm 8.5.0 and node 12.22.10 and first tried it as root, then according to your hint with nvm, then as a new user "lightningcharge" with the changed default directory according to your link. But still getting the "Undefined variable module_name in binding.gyp while trying to load binding.gyp" error.

lightningcharge@server:~$ npm install -g lightning-charge -verbose
... lots of packages installed just fine, then ...
npm timing build:queue Completed in 46ms
npm timing build:link:node_modules/lightning-charge Completed in 2ms
npm timing build:link Completed in 3ms
npm info run sqlite3@5.0.2 install node_modules/lightning-charge/node_modules/sqlite3 node-gyp rebuild
npm info run sqlite3@5.0.2 install { code: 1, signal: null }
npm timing reify:rollback:createSparse Completed in 2496ms
npm timing reify:rollback:retireShallow Completed in 0ms
npm timing command:install Completed in 16761ms
npm verb stack Error: command failed
npm verb stack at ChildProcess. (/usr/local/lib/node_modules/npm/node_modules/@npmcli/promise-spawn/index.js:64:27)
npm verb stack at ChildProcess.emit (events.js:314:20)
npm verb stack at maybeClose (internal/child_process.js:1022:16)
npm verb stack at Socket. (internal/child_process.js:444:11)
npm verb stack at Socket.emit (events.js:314:20)
npm verb stack at Pipe. (net.js:675:12)
npm verb pkgid sqlite3@5.0.2
npm verb cwd /home/lightningcharge
npm verb Linux 5.4.0-99-generic
npm verb argv "/usr/bin/node" "/usr/local/bin/npm" "install" "-g" "lightning-charge" "-verbose"
npm verb node v12.22.10
npm verb npm v8.5.0
npm ERR! code 1
npm ERR! path /home/lightningcharge/.npm-global/lib/node_modules/lightning-charge/node_modules/sqlite3
npm ERR! command failed
npm ERR! command sh -c node-gyp rebuild
npm ERR! gyp info it worked if it ends with ok
npm ERR! gyp verb cli [
npm ERR! gyp verb cli '/usr/bin/node',
npm ERR! gyp verb cli '/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js',
npm ERR! gyp verb cli 'rebuild'
npm ERR! gyp verb cli ]
npm ERR! gyp info using node-gyp@8.4.1
npm ERR! gyp info using node@12.22.10 | linux | x64
npm ERR! gyp verb command rebuild []
npm ERR! gyp verb command clean []
npm ERR! gyp verb clean removing "build" directory
npm ERR! gyp verb command configure []
npm ERR! gyp verb find Python Python is not set from command line or npm configuration
npm ERR! gyp verb find Python Python is not set from environment variable PYTHON
npm ERR! gyp verb find Python checking if "python3" can be used
npm ERR! gyp verb find Python - executing "python3" to get executable path
npm ERR! gyp verb find Python - executable path is "/usr/bin/python3"
npm ERR! gyp verb find Python - executing "/usr/bin/python3" to get version
npm ERR! gyp verb find Python - version is "3.8.10"
npm ERR! gyp info find Python using Python version 3.8.10 found at "/usr/bin/python3"
npm ERR! gyp verb get node dir no --target version specified, falling back to host node version: 12.22.10
npm ERR! gyp verb command install [ '12.22.10' ]
npm ERR! gyp verb install input version string "12.22.10"
npm ERR! gyp verb install installing version: 12.22.10
npm ERR! gyp verb install --ensure was passed, so won't reinstall if already installed
npm ERR! gyp verb install version is already installed, need to check "installVersion"
npm ERR! gyp verb got "installVersion" 9
npm ERR! gyp verb needs "installVersion" 9
npm ERR! gyp verb install version is good
npm ERR! gyp verb get node dir target node version installed: 12.22.10
npm ERR! gyp verb build dir attempting to create "build" dir: /home/lightningcharge/.npm-global/lib/node_modules/lightning-charge/node_modules/sqlite3/build
npm ERR! gyp verb build dir "build" dir needed to be created? Yes
npm ERR! gyp verb build/config.gypi creating config file
npm ERR! gyp verb build/config.gypi writing out config file: /home/lightningcharge/.npm-global/lib/node_modules/lightning-charge/node_modules/sqlite3/build/config.gypi
npm ERR! gyp verb config.gypi checking for gypi file: /home/lightningcharge/.npm-global/lib/node_modules/lightning-charge/node_modules/sqlite3/config.gypi
npm ERR! gyp verb common.gypi checking for gypi file: /home/lightningcharge/.npm-global/lib/node_modules/lightning-charge/node_modules/sqlite3/common.gypi
npm ERR! gyp verb gyp gyp format was not specified; forcing "make"
npm ERR! gyp info spawn /usr/bin/python3
npm ERR! gyp info spawn args [
npm ERR! gyp info spawn args '/usr/local/lib/node_modules/npm/node_modules/node-gyp/gyp/gyp_main.py',
npm ERR! gyp info spawn args 'binding.gyp',
npm ERR! gyp info spawn args '-f',
npm ERR! gyp info spawn args 'make',
npm ERR! gyp info spawn args '-I',
npm ERR! gyp info spawn args '/home/lightningcharge/.npm-global/lib/node_modules/lightning-charge/node_modules/sqlite3/build/config.gypi',
npm ERR! gyp info spawn args '-I',
npm ERR! gyp info spawn args '/usr/local/lib/node_modules/npm/node_modules/node-gyp/addon.gypi',
npm ERR! gyp info spawn args '-I',
npm ERR! gyp info spawn args '/home/lightningcharge/.cache/node-gyp/12.22.10/include/node/common.gypi',
npm ERR! gyp info spawn args '-Dlibrary=shared_library',
npm ERR! gyp info spawn args '-Dvisibility=default',
npm ERR! gyp info spawn args '-Dnode_root_dir=/home/lightningcharge/.cache/node-gyp/12.22.10',
npm ERR! gyp info spawn args '-Dnode_gyp_dir=/usr/local/lib/node_modules/npm/node_modules/node-gyp',
npm ERR! gyp info spawn args '-Dnode_lib_file=/home/lightningcharge/.cache/node-gyp/12.22.10/<(target_arch)/node.lib',
npm ERR! gyp info spawn args '-Dmodule_root_dir=/home/lightningcharge/.npm-global/lib/node_modules/lightning-charge/node_modules/sqlite3',
npm ERR! gyp info spawn args '-Dnode_engine=v8',
npm ERR! gyp info spawn args '--depth=.',
npm ERR! gyp info spawn args '--no-parallel',
npm ERR! gyp info spawn args '--generator-output',
npm ERR! gyp info spawn args 'build',
npm ERR! gyp info spawn args '-Goutput_dir=.'
npm ERR! gyp info spawn args ]
npm ERR! gyp: Undefined variable module_name in binding.gyp while trying to load binding.gyp
npm ERR! gyp ERR! configure error
npm ERR! gyp ERR! stack Error: gyp failed with exit code: 1
npm ERR! gyp ERR! stack at ChildProcess.onCpExit (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/configure.js:259:16)
npm ERR! gyp ERR! stack at ChildProcess.emit (events.js:314:20)
npm ERR! gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:276:12)
npm ERR! gyp ERR! System Linux 5.4.0-99-generic
npm ERR! gyp ERR! command "/usr/bin/node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
npm ERR! gyp ERR! cwd /home/lightningcharge/.npm-global/lib/node_modules/lightning-charge/node_modules/sqlite3
npm ERR! gyp ERR! node -v v12.22.10
npm ERR! gyp ERR! node-gyp -v v8.4.1
npm ERR! gyp ERR! not ok
npm verb exit 1
npm timing npm Completed in 17475ms
npm verb unfinished npm timer reify 1644956489303
npm verb unfinished npm timer reify:build 1644956502449
npm verb unfinished npm timer build 1644956502454
npm verb unfinished npm timer build:deps 1644956502454
npm verb unfinished npm timer build:run:install 1644956502506
npm verb unfinished npm timer build:run:install:node_modules/lightning-charge/node_modules/sqlite3 1644956502508
npm verb code 1

npm ERR! A complete log of this run can be found in:
npm ERR! /home/lightningcharge/.npm/_logs/2022-02-15T20_21_28_621Z-debug-0.log
lightningcharge@server:~$

@SeverinAlexB
Copy link

Same here.

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

4 participants