question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

JavaScript error running Windows packaged app

See original GitHub issue

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

> electron1@1.0.0 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

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

2reactions
maleptcommented, Sep 16, 2016

@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.

0reactions
TracyGJGcommented, Sep 20, 2016

All working following the good advice received.

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

Read more comments on GitHub >

github_iconTop Results From Across the Web

JavaScript error running Windows packaged app #492 - GitHub
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...
Read more >
A Javascript Error Occurred in the Main Process Windows 10 ...
A Javascript Error Occurred in the Main Process Windows 10/8/7 FIX.The “A JavaScript error occurred in the main process” error usually ...
Read more >
Javascript void error while trying to download an application ...
Can't seem to install JAVA, it said to uninstall older ones first; trying to uninstall older ones I get a message to find...
Read more >
How to resolve React Native package error issue and run the ...
Trying to run an existing react native app after cloning it into my system => weather-app in windows but getting the below package...
Read more >
4 Ways to Fix a Javascript Error in Windows 10 - wikiHow
1. Open your antivirus or antimalware software. If you're unable to install Discord or another app on your PC because of a JavaScript...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found