args icon indicating copy to clipboard operation
args copied to clipboard

This package fails after used in built electron app.

Open wmantly opened this issue 4 years ago • 1 comments

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 avatar Sep 18 '21 23:09 wmantly

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

eduardoleolim avatar Apr 10 '23 01:04 eduardoleolim