Require electron from node_modules of a parent directory


Is it possible to require the electron package from a node_modules folder that exists on a parent directory above the main.js? Below is my folder structure:

When I execute electron, I get the following error:



Are you talking about the electron package on NPM or the built-in electron module referenced in the Electron docs? Accidentally installing the NPM package (which has nothing to do with Electron) was a common source of errors for new users prior to Electron v1.1.2.


I am referring to the electron-prebuild module.


The error was due to absence of package.json file. Specifically, Electron could not find the main.js file to load, which is declared in the json file.

Thanks for your help anyway!