Cannot read property 'module' of undefined while building angular lib

If angular decides to fail on aot compilation, you could try to go into node_modules\@angular\compiler-cli\src\metadata\bundler.js and do some console logging in that file. I would start from placing console.log in convertSymbol function. enter image description here That should provide you with some information about the file path which angular cli used before falling on module compilation. For example in my case, it was the re-export of the constant from the barrel which broke the compilation enter image description here So finding all the usages of TWO_FA_INITIAL_STATE, and directly importing TWO_FA_INITIAL_STATE, fixed that particular problem.