Is there any way to know which Angular CLI version to install which is compatible with my Angular Core version? Are they completely independent?
Working on an existing Angular App with Core v5.2.8, I see they use CLI v6.0.8 so I was wondering which version of CLI should we use?
The compatibility between Angular CLI & Angular Core is documented nowhere.
A common thing which people do is always use the global install. This can however cause inconsistencies with older projects.
The versions in your package.json
should always be compatible.
To be sure you run the local version do this:
npm run -- ng generate component foo
Instead of this:
ng generate component foo
It will then always use the local version.
Yarn passes all params so it doesn't need the ugly annotation:
yarn run ng generate component foo
A good example for this is e.g. how Angular deals with service DI. Whereas in previous versions it was necessary to add each service to the app module as a provider.
This was changed in version 6 so this actually is really relevant:
In v6 and later versions of Angular the @Injectable
decorator was extended with the capability which lead to a different boilerplate:
Before:
@Injectable()
After:
@Injectable({
providedIn: 'root'
})
Thereby removing the necessity to add all services to the app module within an app.
So creating a service from CLI v6 produced a template which was not compatible with v5.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With