I did this:
npm install @angular-devkit/build-angular ng-packagr --save-dev
Notice the space before ng-packagr!
That was the solotion for angular18.