-
Notifications
You must be signed in to change notification settings - Fork 4.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
TypeError: Cannot read property 'on' of undefined #30
Comments
Having the exact same problem.. Tried to use the downloaded .exe, update node, clean cache and re-install electron-prebuilt, and nothing.. I either get an error that module electron can't be found (with require('electron') ) or that app is undefined with require('electron-prebuilt') |
I have the same issue here. |
@dmr, no, i switched to nw.js. |
The issue is also discussed in the electron main repo:
Solved the issue for me :) |
Anyone interested in a pull request? |
@dmr, I think that working example better. |
I think the issue was/is my computer. I had to manually look for a node_modules/electron folder and delete is. Sorry for the noise. |
@chezstov do you have a globally installed |
@jlord |
That is exactly the problem. Remove alle the electron installations and install electron-prebuilt, then it works. |
Yep, @dmr. 👍 If you have a globally installed module called // cc @chezstov @vertexportus |
Going to close this out, hopefully the last response helped others in this thread. |
@dmr I can't make it work with that, can you put here a copy of your main.js? It would be great. |
This issue is really old. Removing node_modules and reinstalling will probably fix the issue |
Removing Here is what I've done:
Here is the error message:
Node version: System is GNU/Linux running Linux Mint 18 Cinnamon 64 Bit |
Same for me. electron-prebuilt is not a fix. and .on is called on a null object. |
The name "electron-prebuilt" is changed (back?) to "electron" since mid-2016 by the development team. |
The thing is, although I get this error, it's still working?! createWindow gets executed. |
One potential cause of this problem can be tied back to executing the electron app from a terminal extension in the Atom editor. This answer on StackOverflow helped me get past the problem: http://stackoverflow.com/a/40664925/1076507. Using a system terminal instead of platformio-ide-terminal plugin inside the Atom editor addressed my problem. |
@boredwookie Thanks you! Made it all the way down here thinking I was borked and then found your working solution. Thank you for saving me many hours of frustrating troubleshooting. This is the issue, not sure what's up with the electron terminal extension not issuing this properly but whatever... small steps. =) |
@boredwookie man you saved me a lot of time i'm so used to that plugin that I didn't think about it |
@boredwookie Thank you god. |
Hitting same problem on MacOS Sierra, Node 8.1.0, VSCode / Terminal / iTerm - doesn't matter. What is causing this? |
Will second @bluemoehre here: following the quickstart to the letter, getting a
Also, there is a global |
Oh, apologies, my mistake. I did not know that in the line |
I realized that I included |
@boredwookie thank you, this solved my issue and likely saved me hours of trial and error |
@boredwookie Do you have any idea what causes this? I'd been using Terminal-Fusion (which is a Linux fork of Platformio Term), and had the same problem. Any idea what the cause is? |
I'm using VS Code to develop Angular JS application and I have exactly the same problem as VS Code is built on top of Atom. The problem is that you have the same problem using the debugger tool in VS Code... so: no Atom terminal means no debugger. Using the Ubuntu terminal instead the Atom/VS Code terminal is a workaround, not a solution: needs to makes electron working with Atom terminal. |
I'm running into this as well with VS Code |
Do we think it's an atom bug then, rather than the specific terminal? |
@searene Cheers, that's what I did too. Would've taken me forever to figure it out. |
Missing below step will cause this issue:
|
For me using |
One implication of this issue appears to be that an electron application cannot be launched from a node script via a |
At this point it seems like a rather problematic electron bug. Maybe do some digging and see if you can find out what's causing it. Just happens when running via node API calls? Can you call it using the node runtime but using a lower-level interface (is there a way to use raw syscalls in node)? |
I'm very new to Electron but I figured out the solution to my problem: I have a very basic Electron application that consists of two files:
I got the error "Uncaught TypeError: Cannot read property 'on' of undefined", in the dev-tools console, despite my application opening and functioning properly. My mistake: I had added a <script src = "path/to/main.js"> in my index.html file, because I wanted an onclick-event to call a function in my main.js Removing this <script> tag removed the error. |
With electron 2.0, this is what works in the renderer process:
|
The worked for me in VSCode create .vscode folder in root and create launch.json {
} |
For me this error happened when I, like searene above, occasionally linked |
replace your scripts with: |
sanks;) |
In my application it's throwing different error like If we have any solution please help me. |
In my case the solution appears after check the python-shell official documentation. 'electron' is correct and be sure to pass run function all the parameters that the function needs (following some tutorials, I was not writting arguments:
Hope be useful! |
Apparently this is the case why it was showing an exception in VS Code while debugging. It did run in power-shell terminal but showed exception in VS Code debugger, the solution was to add a configuration file for debugging. Make sure to uncheck, 'All Exceptions' and 'Uncaught Exceptions' from the debugger window. It should debug smoothly. |
write app in lower case |
macOS Catalina problem solved by adding into package json "electron ." |
|
Deleting you local node_modules folder and reinstalling does not fix the problem. |
On Windows tried to use PowerShell and command prompt outside of Visual Studio. Still getting the same error. |
If you use the example project you can see that they are calling
I wish they were more transparent about this in their documentation. |
Thank you, this worked for me. |
After
I get error:
The text was updated successfully, but these errors were encountered: