rhysd / electron-about-window

'About This App' mini-window for Electron apps
https://www.npmjs.com/package/about-window
MIT License
409 stars 46 forks source link

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

Open ndom91 opened 4 years ago

ndom91 commented 4 years ago

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.

rhysd commented 4 years ago

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