Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Compatibility between Angular CLI version & Angular Core version?

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.

like image 267
hzitoun Avatar asked Nov 06 '22 22:11

hzitoun


1 Answers

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.

like image 92
mchl18 Avatar answered Nov 13 '22 06:11

mchl18