My Electron application has the following directory structure:
app | node_modules | | electron-prebuilt | output | | Prelude main.js
If I run
NODE_PATH=output node I can use
main.js requires Prelude though, I get the following Error when running electron:
$ NODE_PATH=output node_modules/.bin/electron main.js Error opening app The app provided is not a valid electron app, please read the docs on how to write one: https://github.com/atom/electron/tree/master/docs Error: Cannot find module 'Prelude'
If I copy the contents of `output/` into `node_modules/` the app starts fine but I want to keep the two directories seperate. How can I make electron respect NODE_PATH or add folders to it's require path. Edit [quote="kRITZCREEK, post:7, topic:21757, full:true"] For anyone struggling like I did, I finally found a solution here; https://github.com/atom/electron/issues/11 Adding this to the top of my main.js file that starts the Electron application solved it. //main.js require('module').globalPaths.push(__dirname + "/output"); var app = require('app'); // Module to control application life. ... [/quote]