Cannot find module 'nw.gui' - node webkit updater - node.js

I'm trying to use node webkit updater for my aplication,but when i'm trying to test is(using npm test) or start it(using nmp start) i'm receiving this error .Both commands are used from Nodejs command prompt .
The js file used is updaterClientABC.js and the error comes from this line: var gui = require('nw.gui');
This is my folder structure :
Can you please tell me what should i do ? I admit that i am a beginner i've never worked with node-webkit.Some advices will be very helpful :)

I noticed this thread:
node module 'nw.gui' not found
So yes, this kind of thing is due to how NW.js gets called (directly or from within a project). I've run into this problem as well. In this case, in the above, you call updaterClientABS.js directly from node.js. To run a node-webkit project you need to load it via the NW.js binary, which in turn requires node.js.
It's also possible, as was my problem with this, that I was trying to access the nw.gui within the Node context (vs browser context). My solution was to access it via the browser context (which has more global access, not just Node.js objects).

Related

Express JS in Altassian Forge causing "process.cwd is not a function" error

I am new to development on Jira Cloud and am currently exploring creating apps using the Atlassian Forge. I was trying to use Express JS in the code as a middleware. Turns out that during deployment, it keeps giving this error "process.cwd is not a function."
The error received while deploying the app.
I tried installing process module (via npm i process; which was successfully done) and updating the webpack version but none of it worked.
Can someone please tell what could be causing this error?
If possible please suggest the alternative for using Express JS in Altassian Forge?
Thanks in advance.
Apoorva
From the documentation:
When a Forge app is invoked, the JavaScript code is executed within the app sandbox. This environment differs from a traditional Node.js environment you might already be familiar with.
You'll need to write your functions in a subset of Node.js. Some globals are not exposed, for example:
process (except for process.env)
queueMicrotask
which means that some NPM packages that depend on these may not function correctly.
If Express JS depends on process.cwd(), that would explain the error. You may be able to work around this if it depends on it in theory but not in practice:
If process.cwd() is only used in test cases or example code, you can delete it or make sure it's not bundled.
If it is used, but using a dummy string like "/" would work, you could stub out the call using DefinePlugin or similar.

Electron: how to expose console.log calls from installed packages?

still new to Electron/Node and am trying to debug an issue I'm experiencing with the msnodesqlv8 package. In the file that throws errors (bootstrap.js) there are several console.log(...) calls that do not appear in the DevTools console or in the command prompt where electron was called either, like those that are called in the renderer process. Is there anything that I can do to see where this is being logged?
This code is an out of the box installation of the Electron React Boilerplate with nothing changed besides the installation of the msnodesqlv8 package and one line added to index.js to require it.
I have attempted to connect a separate DevTools instance to the main process debugger through electron's --inspect flag per Electron and Node guides, but they are incomplete/outdated and I cannot form the necessary connection -- or at least do not know where to find the complete information.
Sorry for the beginner question but I am a bit lost here.

node js - How do I create build for commercial usage?

I am working on node js application and it is now ready to use. I want to make exe of this application so that it can be used for commercial usage.
Up to now I have used enclose module using which I have compiled the code of application but I have found some issues in that (app got crash on idle condition). App is running good without enclose or compiled code.
I have searched on google and found some alternate modules like JXcore, Node webkit and Electron etc. but JX core giving error same as in SO question.
In node web-kit, it's functionality is not looking suitable as we need its executable and some dll's along with our code, which makes our package bulky.
I have also tried jxcore. The main problem with the exe's and with modules that we use is their ability to work with native modules, in my case the Kinect.node module. This module cannot be compiled. We need a workaround to package only this along with our .exe file. Enclose provides this workaround in its inbuilt functionality.
Also looking a response from EncloseJS, which is actually run by just one person who gives further instructions upon purchase. A purchase is needed for commercial usage.
In case of Electron, It is supporting only Electron-based application source code. So If I choose this then I have to modify my application code.
So can any one suggest me what can I do to make exe file from node js code there?
Thank you!
I had the same issue before, the node js application close when running in background. now i am using process manager2 (pm2), it is working fine and if the application is crash due to any other reason it is automatically started again.
I have gotten my answer:
First, reason was DiskDB database, it was not compatible with the node webkit so that is why I was getting error of native modules.
Now I am using sqlite3 module for local database. It is better than DiskDB.
Second, One reason was free version of enclose, Paid version of Enclose JS module ignores the timeout issue which I was getting.
This way I have resolved my question.

Headless browser automation app via electron js app

I would like to create an electron app that can do some web automation based on user input into a GUI. In my research it seems my two best bets are Phantom and Selenium+Chromedriver.
The thing I'd like to do is have an app that someone else could download and run without any additional setup. It seems with Chromedriver and Phantom that I'd need to have others download and add these things to their PATH. In order to get things functioning.
Is there a way around this? Or is there another approach I should be taking? Any advice is appreciated. Thanks!
First off, you should have a look at Nightmare.js which is like PhantomJS in many ways, but uses Electron under the hood (and that's good, because Chromium in Electron is very fresh compared to PhantomJS engine).
If you still want to use PhantomJS in Electron that's quite fine too. You may bundle it with your application or install npm module as a dependency and require that in your script. The main thing is - PhantomJS will be installed together with your app and you know the path to that folder.

Running Protractor from Node-webkit

Is is possible to run Protractor in any other way except using CLI?
Is there an API call which will simulate the command: 'protractor config file.js'?
I would like to start a test through a node-webkit application, and even though I can connect directly to the ChromeDriver through the directConnect parameter, this is no use if I can't run protractor from inside the script.
Of course, this is in an environment where Node and Protractor aren't available from CLI... simulating a distribution environment where the user doesn't have to install additional apps apart from my node-webkit (hence the node-webkit usage).
Thank you in advance for any pointers!
The protractor command line script boils down to invoking lib/cli.js which mostly deals with parsing commmand-line arguments and then invokes lib/launcher.js to actually start protractor.
I don't think any special concessions have been made in these files to be directly invoked programmatically, but I don't see any particular hurdles either.

Resources