DEV Community

Discussion on: Electron with Typescript using ts-node

Collapse
 
xemanet profile image
xemanet

Hello Michael

I'm create a SSR with typescript and node-express-react-mongoDB-sequelize-mysql and I want integrate with electron to run on the win desktop. Thats all! ;)

All run correctly but there is no human way to make it work whith electron.

Imports errors, Document is not defined, electron window no open...etc

Can you tell me some resources where to find help on this?.

Thanks!

Collapse
 
michaeljota profile image
Michael De Abreu

Hi! You may face some troubles with native modules in the first place, as Electron bundle its own version of Node, that may or may not be different from yours.

Aside of this, what are your expectations of this applications? Does this should run on it's own? Does this should display data from an api REST? It really depends upon what you are expecting to archive.

If you want an application that runs on its own, and need a database, I would suggest you to use another kind of database. Maybe rxdb, that have a mongo compatible query system.

If you want an applications that display data from an api REST, then you just want to use the React part of the app. You may want to separate the React client entirely of the stack, to be able to use it in Electron and in Express.

You could setup an express server inside the Electron app, but this is kind of unlikely scenario to be needed.

Collapse
 
xemanet profile image
xemanet

Hi!

This app will have to work in a Pc windows that has installed a business management application(BMA) with mysql and apache(nginx). The user has a online shop in internet(mysql) and this app will manage actualized regs between BMA and Online Shop.(Clients, orders, products and products' images).
This app contains a poolling loop(4 timers) when opening it that run on , Socket.io to comunicate with user in react page, mongodb for store logs in pc and default values(mongodb) that user can modify with comunicate with databases with get and post of express.

I have separate server and client, and webpack compile in dist folder.

All run correctly in development and production.
The next step was integrate electron in app and this is the problem.

All app was write in nodejs javascript with babel and babel node for run it to use imports instead of require, and with errors of electron I opted to change the code to Typescript(much better of course) but the errrors continue.
If in main entry of pckage.jsfor I indicate dist/client.js, electron send error "document is not defined". If I indicate production.ts send error in imports Unexpected identifier.

I'm a bit lost and I do not find much on the internet.
Can you give me some information about it?

Thank you very much for answering!!

Thread Thread
 
michaeljota profile image
Michael De Abreu

You want to bundle the React app into Electron, so you would probably need to do just that. Have you try to create an Electron application before? The tutorial is very useful for a first app. :).

Thread Thread
 
xemanet profile image
xemanet

ok, thanks for your help.