From ad3065f08ae930d3796dfc81c1b3e435b6c71045 Mon Sep 17 00:00:00 2001 From: Max Claus Nunes Date: Mon, 6 Jun 2016 11:47:43 -0700 Subject: [PATCH] docs: Add docs about how to manually load app deps (#473) --- docs/Loading App Dependencies Manually.md | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 docs/Loading App Dependencies Manually.md diff --git a/docs/Loading App Dependencies Manually.md b/docs/Loading App Dependencies Manually.md new file mode 100644 index 00000000000..6229be59fa2 --- /dev/null +++ b/docs/Loading App Dependencies Manually.md @@ -0,0 +1,20 @@ +> Important: This approach must be used only in development environment. +> Since the release version of your application the `app` directory should self contain all used files. + +In case on development environment your app runs the main process (executed by electron) not inside the `/app` folder. You may need to load the `/app` dependencies manually. Because the app dependencies are be placed at `/app/node_modules` and your main process that is running in a different directory will not have access by default to that directory. + +Instead of duplicating the app dependencies in the development `package.json` it is possible to make the electron main process load the app dependencies manually with an approach like this: + +```js +// Given this file is: /src/browser/main.js + +var path = require('path'); + +var devMode = (process.argv || []).indexOf('--dev') !== -1; + +if (devMode) { + // load the app dependencies + var PATH_APP_NODE_MODULES = path.join(__dirname, '..', '..', 'app', 'node_modules'); + require('module').globalPaths.push(PATH_APP_NODE_MODULES); +} +```