Adding Dependencies
Add modules to the project#
You will need to add other modules to this boilerplate, depending on the requirements of your project. For example, you may want to add node-postgres to communicate with PostgreSQL database, or material-ui to reuse React UI components.
tip
Please read the following section before installing any dependencies
Module Structure#
This boilerplate uses a two package.json structure. This means you will have two package.json files.
./package.jsonin the root of your project./build/app/package.jsonrelative to the project root
Which package.json file to use#
Rule of thumb is: all modules go into ./package.json except for native modules, or modules with native dependencies or peer dependencies. Native modules, or packages with native dependencies should go into ./build/app/package.json.
- If the module is native to a platform (like node-postgres), it should be listed under
dependenciesin./build/app/package.json - If a module is
imported by another module, include it independenciesin./package.json. See this ESLint rule. Examples of such modules arematerial-ui,redux-form, andmoment. - Otherwise, modules used for building, testing, and debugging should be included in
devDependenciesin./package.json.
Further Readings#
- See Electron Documentation - Using Native Node Modules to see how Electron uses native Node modules.
- See Node.js Documentation - Addons to see what are native Node modules.
For an example app that uses this boilerplate and packages native dependencies, see erb-sqlite-example.