Can Electron be used to do all things that can be done by nodejs?


I want to make a desktop application that would need to manage files and directory. Creating, renaming, editing, moving and deleting files and directory is one of the basic need of my app. Also I want to use Javascript (I guess it is nodejs) to manage XML files. Can this be done in electron?


Yes. Electron is just the means for creating a graphical front-end that uses the Chromium engine to render web code into a user interface. If you can find a Node package for it, you can implement the functionality in Electron.


why can’t I run nodejs commands in js files?


What exactly do you mean by nodejs commands?


If I put these lines in Javascript file included in index.html file

cannot run const electron = require('electron');
const app =;

I get this error in browser console: Uncaught TypeError: Cannot read property 'getAppPath' of undefined


This may be a stupid question but was this code in a script tag? Also… you don’t have access to app from the renderer process. You would have to…
const {remote} = require('electron') const {app} = remote console.log(app.getAppPath())


yes, those lines are in script tag.
how come your code works?
thanks for your help!


Check the Electron docs and the center column is divided into Main Process, Renderer Process, and Both Processes. Therefore, the things listed under each are only available within that process. The app module that you were attempting to use is only available within the main process (e.g. the main.js file that was used to launch electron). The app module isn’t available in the Renderer process. If you need access to modules that are available only in the Main process, from the Renderer process (from your html or js loaded in your html) you have to use the remote module. The code above loads the remote module from the base electron module and then makes use of app, that is available on the remote module