question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Pass command line arguments to node-gyp

See original GitHub issue

I have an electron application which depends on a native module that I am writing.

When I run electron-forge package, it fails at Preparing native dependencies: 0/1:

gyp: Undefined variable BASE_DIR in binding.gyp while trying to load binding.gyp

I usually pass the BASE_DIR as a command line argument to node-gyp (this also works for npm install):

node-gyp rebuild --BASE_DIR=`pwd`
npm install ../addon --BASE_DIR=`pwd`

Is there a way to pass this command line argument with electron-forge? I have tried

electron-forge package --BASE_DIR=`pwd`

but this does not work:

$ electron-forge package --BASE_DIR=`pwd`
√ Checking your system
  error: unknown option `--BASE_DIR'

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
MarshallOfSoundcommented, Feb 27, 2017

I believe they do in the case of node-gyp but I consider that unsafe as it means random args can flow down the spawn tree and cause unexpected behavior.

0reactions
MarshallOfSoundcommented, Apr 16, 2018

Closing this out as it should be tracked upstream in electron-rebuild if it isn’t already 👍

Read more comments on GitHub >

github_iconTop Results From Across the Web

Pass command line arguments to node-gyp #150 - GitHub
I have an electron application which depends on a native module that I am writing. When I run electron-forge package, it fails at...
Read more >
How do I pass command line arguments to a Node.js program?
The simplest way of retrieving arguments in Node.js is via the process.argv array. This is a global ...
Read more >
How do I pass command line arguments to a Node.js program?
We can pass any number of command-line arguments while invoking a Node.js application by typing them in after the name of the file,...
Read more >
How To Pass Command-Line Arguments in Node.js (2022)
argv property returns an array containing the command-line arguments passed when the Node.js process was launched. The first element will be process.execPath ....
Read more >
How To Handle Command-line Arguments in Node.js Scripts
Node.js supports a list of passed arguments, known as an argument vector. The argument vector is an array available from process.argv in your ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found