angular get version from package.json code example

Example: angular get version from package.json

In your /tsconfig.json (sometimes also necessary in 
/src/tsconfig.app.json) enable the resolveJsonModule 
option (webpack dev server restart required afterwards):

"compilerOptions": {
      ...
      "resolveJsonModule": true
      ...
}

Then in your component, for example /src/app/app.component.ts
use the version info:

import { version } from '../../package.json';
...
export class AppComponent {
      public version: string = version;
}

Tags:

Misc Example