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

This package fails after used in built electron app. #158

Open
wmantly opened this issue Sep 18, 2021 · 1 comment
Open

This package fails after used in built electron app. #158

wmantly opened this issue Sep 18, 2021 · 1 comment

Comments

@wmantly
Copy link

wmantly commented Sep 18, 2021

I am trying to use this package with an electron app. In development, everything works fine. Once the package is built, I get this error:

TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received undefined
    at validateString (internal/validators.js:124:11)
    at Object.basename (path.js:1241:5)
    at Args.module.exports [as parse] (/tmp/.mount_MorphwR9fp7L/resources/app.asar/node_modules/args/lib/parse.js:38:22)
    at Object.<anonymous> (/tmp/.mount_MorphwR9fp7L/resources/app.asar/conf/index.js:66:8)
    at Module._compile (internal/modules/cjs/loader.js:1083:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1113:10)
    at Module.load (internal/modules/cjs/loader.js:940:32)
    at Module._load (internal/modules/cjs/loader.js:781:14)
    at Function.f._load (electron/js2c/asar_bundle.js:5:12913)
    at Module.require (internal/modules/cjs/loader.js:964:19) {
  code: 'ERR_INVALID_ARG_TYPE'
}

Line 66 is this

args.parse(process.argv)

And this is what process.argv is

[ '/tmp/.mount_MorphwD1YseX/morphware-wallet']

Is there a way to fix this?

@wmantly wmantly changed the title This package fails after used when built with electron. This package fails after used in built electron app. Sep 18, 2021
@eduardoleolim
Copy link

eduardoleolim commented Apr 10, 2023

you can use electron.app.commandLine.getSwitchValue('flag') to get the value from process.argv

main.js

import { app } from 'electron';

const flag = app.commandLine.getSwitchValue('arg1');

console.log(flag)

command

electron main.js --arg1=value

Documentation

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

2 participants