Linking an Angular library to an Angular app throw an error after calling the page via localhost

Viewed 53

Linking an Angular library to an Angular app throws the following error:

core.mjs:6494 ERROR TypeError: Cannot read properties of null (reading 'bindingStartIndex')
    at Module.ɵɵelementStart (core:14545:1)
    at GreenTextComponent_Template (libs-my-lib.mjs:13:199)
    at executeTemplate (core.mjs:9632:1)
    at renderView (core.mjs:9432:1)
    at renderComponent$1 (core.mjs:10739:1)
    at renderChildComponents (core.mjs:9297:1)
    at renderView (core.mjs:9457:1)
    at renderComponent$1 (core.mjs:10739:1)
    at renderChildComponents (core.mjs:9297:1)
    at renderView (core.mjs:9457:1)

For reproduction purposes I have created a very simple Angular app und library.
The app simple uses the library to display some green text.

Library:
https://github.com/obas9000/my-lib

App:
https://github.com/obas9000/my-app

Using node v14.15.0 (npm v6.14.8) everything works fine. Since using v16.15.0 (npm v8.5.5) the above described error appears.

Steps:

  1. Clone the lib
  2. cd pathToLib/my-lib
  3. nvm use 16.15
  4. npm i
  5. npm run build
  6. npm run link
  7. Clone the app
  8. cd pathToApp/my-app
  9. nvm use 16.15
  10. npm i
  11. npm link @libs/my-lib
  12. ng serve
  13. go to localhost:4200

I you use nvm use 14.15 everything would work without any error.

Does anybody has an idea how to solve this error?

0 Answers
Related