Electron-packager: JavaScript error running Windows packaged app

Created on 16 Sep 2016  路  5Comments  路  Source: electron/electron-packager

Build and Target platform: Windows 7 64bit
Running the generated Exe results in an error dialog being presented reporting
"A JavaScript error occurred in the main process". "Uncaught Exception: TypeError: Cannot read property 'require' of undefined at Object.<anonymous>"

Console output during build

> [email protected] build C:\Users\gilmore_tj\Documents\NodeJS\Electron1
> electron-packager . Electron1 --ignore=node_modules/electron-*

Error output during build

Fri, 16 Sep 2016 07:35:18 GMT electron-packager Electron Packager 8.0.0
Fri, 16 Sep 2016 07:35:18 GMT electron-packager Node v6.3.1
Fri, 16 Sep 2016 07:35:18 GMT electron-packager Host Operating system: win32 (x64)
Fri, 16 Sep 2016 07:35:18 GMT electron-packager Packager Options: {"_":[".","Electron1"],"all":false,"deref-symlinks":true,"download":{"strictSSL":true},"overwrite":false,"prune":true,"ignore":"node_modules/electron-*","dir":".","name":"Electron1","protocols":[]}
Fri, 16 Sep 2016 07:35:18 GMT electron-packager Target Platforms: win32
Fri, 16 Sep 2016 07:35:18 GMT electron-packager Target Architectures: x64
Fri, 16 Sep 2016 07:35:18 GMT electron-packager Inferring app-version from version in package.json
Fri, 16 Sep 2016 07:35:18 GMT electron-packager Inferring target Electron version from electron-prebuilt dependency or devDependency in package.json
Fri, 16 Sep 2016 07:35:18 GMT electron-packager Application name: Electron1
Fri, 16 Sep 2016 07:35:18 GMT electron-packager Target Electron version: 1.4.0
Fri, 16 Sep 2016 07:35:18 GMT electron-packager Ignored path regular expressions: [ 'node_modules/electron-*',
  '/node_modules/electron($|/)',
  '/node_modules/electron-prebuilt($|/)',
  '/node_modules/electron-packager($|/)',
  '/\\.git($|/)',
  '/node_modules/\\.bin($|/)' ]
Fri, 16 Sep 2016 07:35:18 GMT electron-packager Downloading Electron with options {"strictSSL":true,"platform":"win32","arch":"x64","version":"1.4.0"}
Skipping win32 x64 (output dir already exists, use --overwrite to force)

Package.json command

electron-packager . Electron1 --ignore=node_modules/electron-*

Code provided at https://github.com/TracyGJG/ElectronWindowFault

question

Most helpful comment

@englishextra Unlikely, it appears he's using a pretty old version of electron-prebuilt, not the electron NPM package.

@TracyGJG there are a few things that are inconsistent in your example:

  • You're using Electron 0.25.2, which does not have support for the electron module (that was added in 0.35.0, but you should use the newest Electron release if possible).
  • When you run npm start, you're running main.js, but when you run the packaged app, you're running index.js because Electron runs the script in the main section of package.json (see Electron docs)
  • Your ignore flag is incorrect (it is a regular expression, not a glob expression, see the API docs) and unnecessary because by default, Electron Packager removes all packages in devDependencies.

That being said, this doesn't appear to be an Electron Packager specific problem at this time. You may get better help from the greater Electron community.

All 5 comments

electronerror

Can this be of help https://github.com/electron/electron/issues/3708

ALso

--ignore=node_modules/electron-*

shouldn't that be a regexp?

@englishextra Unlikely, it appears he's using a pretty old version of electron-prebuilt, not the electron NPM package.

@TracyGJG there are a few things that are inconsistent in your example:

  • You're using Electron 0.25.2, which does not have support for the electron module (that was added in 0.35.0, but you should use the newest Electron release if possible).
  • When you run npm start, you're running main.js, but when you run the packaged app, you're running index.js because Electron runs the script in the main section of package.json (see Electron docs)
  • Your ignore flag is incorrect (it is a regular expression, not a glob expression, see the API docs) and unnecessary because by default, Electron Packager removes all packages in devDependencies.

That being said, this doesn't appear to be an Electron Packager specific problem at this time. You may get better help from the greater Electron community.

@malept thanks for clarification. Also it seems some module has incompatible checking environment Js wrapper.

All working following the good advice received.

The GitHub repo https://github.com/TracyGJG/ElectronWindowFault has now been deleted.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

quadrophobiac picture quadrophobiac  路  4Comments

Liam-Ryan picture Liam-Ryan  路  4Comments

pushkin- picture pushkin-  路  4Comments

ghost picture ghost  路  3Comments

andreabisello picture andreabisello  路  3Comments