[Fixed] Angular 9 build error for missing peer dependecies


I have an npm module with a peer dependency to electron: the require is inside a function and executed only if needed, so that it can be used both in electron projects and plain javascript projects.

Now I would like to use that module in an Angular 9 project, but when I run ng build I get a module not found error.

How can I tell to Angular compiler to "do not care" about the peer dependecy (something like webpack externals)? It will never be satisfied and the code requiring it will never be called.


Thanks to @rveerd comment I found this tutorial and I have been able to exclude my peer dependency using following webpack configuration file:

const webpack = require('webpack');

module.exports = {
  externals: {
    electron: "electron",

Leave a Reply

(*) Required, Your email will not be published