Skip to content

Commit

Permalink
docs: Add docs about how to manually load app deps (#473)
Browse files Browse the repository at this point in the history
  • Loading branch information
maxcnunes authored and develar committed Jun 6, 2016
1 parent 97e16a2 commit ad3065f
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions docs/Loading App Dependencies Manually.md
Original file line number Diff line number Diff line change
@@ -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);
}
```

0 comments on commit ad3065f

Please sign in to comment.