Search code examples
angularangular-cling-packagrangular12

Angular 12 Unable to load Schema — ng-package.schema.json file inside library


I did upgrade to angular 12 but I'm not able to build libraries anymore. = angular: v12.0.3, ng-packagr: 12.0.0

I'm running the following command ng build mylib --prod and get the following error

Building Angular Package
ERROR: Debug Failure. False expression.
An unhandled exception occurred: Debug Failure. False expression.
See "C:\Users\myuser\AppData\Local\Temp\ng-ql91km\angular-errors.log" for further details.

I then opened the ng-package.json file and saw that I had a warning

{
  "$schema": "../../node_modules/ng-packagr/ng-package.schema.json",
  // ...
}
Unable to load schema from 'c:\Users\myUser\Documents\projects\my-project\my-project-name\node_modules\ng-packagr\ng-package.schema.json': ENOENT: no such file or directory, open 'c:\Users\myUser\Documents\projects\my-project\my-project-name\node_modules\ng-packagr\ng-package.schema.json'.

I did control and the file does exists. I also did try to reinstall every module but didn't fix it.

I have the following folder structure
enter image description here

Does somebody face the same problem?


Solution

  • The reason of the error was for me the following.

    In my ng-pacakge.json I had library that were already enabling, or forcing ivy. But other library weren't. This did create an error, & when running npm i, then it weren't downloading every libraries for some reason.

    The only way to make it worked again was to remove every library that did forced ivy & put them as peerDependencies, or to downgrade them to the correct version that didn't have it yet.