electron-about-window icon indicating copy to clipboard operation
electron-about-window copied to clipboard

`package.json` not found in directory - only in prod

Open ndom91 opened this issue 5 years ago • 1 comments

So in development, the package.json info loads fine, as does the image and the rest of the about-window.

However, in prod I always get an error that about-window: package.json is not found in specified directory path: /opt/company/project/

When I cd /opt/company/project/ there is most definitely a package.json there.

Here is my openAboutWindow config:

openAboutWindow({
    icon_path: path.join(__dirname, '../resources/icons/256x256.png'),
    package_json_dir: path.join(__dirname, '../'),
    product_name: appInfo.name,
    bug_report_url: 'https://git.newtelco.dev/newtelco/billing-parser-1/issue',
    copyright: '2020 Newtelco GmbH',
    homepage: 'https://git.newtelco.dev',
    description: appInfo.description,
    license: appInfo.license,
    adjust_window_size: true,
    win_options: {
      resizable: false,
    },
    show_close_button: 'Close',
  })

I've tried defining the path with __dirname, process.cwd(), and various variations of going up and down directories to land back in the correct one.

Any idea what else I could be missing and/or doing wrong?!

EDIT: I'm also logging process.cwd() and __dirname right before this call and __dirname, for example, comes out to /opt/company/project/app, so a ../ brings one into the project root directoy, where a package.json most definitely is.. I see in the source code that its basically just concatenating package.json onto the path you pass into package_json_dir so I'm really not sure whats going wrong here.

ndom91 avatar Jun 02 '20 12:06 ndom91

The error means require('/opt/company/project/package.json') fails. Open Electron as REPL and try require('/opt/company/project/package.json')

If you pack your app with asar, it may cause some issue

rhysd avatar Jun 05 '20 11:06 rhysd