Those are the most common issue you may face while using electron-to-nwjs. Most of the time, we will fix errors automatically, but in the cases mentioned below, we couldn't do it. If you don't see the issue you are having in that list, open a new issue.
We have support to the nwjs:prebuild
script in that case. Add it to your project scripts
in package.json
.
We have support to the nwjs:postdist
script in that case. Add it to your project scripts
in package.json
.
NW.js didn't support adding an Alt
shortcut, so had to change the shortcut to Alt + M
.
You must load your JS files using the <script src="">
tag, with type="module"
if needed. Loading it with a require
from a HTML file will load the JS file in a different NW.js context, and your application may not work as expected.
We use webpack to transpile your code into NW.js compatible code. Webpack turns everything it touches into modules, so var's are restricted to their JS files. If you need to access a variable from another JS-file, either require/import that file, or place that variable into the global object.
We are not able to support webview's properly at the moment. Try replacing it with an <iframe>
.
Do you have an iframe in that window? In older NW.js versions, an uncaught exception inside an iframe could make NW.js crash. Just add the sandbox
attribute to that iframe, and the problem will be fixed.
Due to a specific need, I need to find out when I'm dealing with Electron and when I'm dealing with NW.js
This is your new best friend. It works in both main and renderer.
const isNWJS = typeof nw !== 'undefined';
Due to a specific need, I need to find out with which NW.js version I'm dealing with inside my application code
If you just need a string with the NW.js version, just access the __nwjs_version
variable. However, if you just need to create a condition involving the NW.js version, there is a more efficient method: use __nwjs_version_(lte|lt|gte|gt)_X_X_X
.
Variables that follow that pattern will be automatically replaced on transpilation time with true
or false
. So, as examples, if you use __nwjs_version_gte_0_20_0
, it will be false
for 0.14.7, but true
for 0.20.0 and 0.21.0.