DEV Community 👩‍💻👨‍💻

Jonathan Flower
Jonathan Flower

Posted on

Display Angular 12 App Version

Displaying the app version automatically pulled from package.json is a great way to ask clients and users to verify what version they are using. It is also helpful to include it in error logging. In previous versions of Angular it was as easy as doing this inside your environment.ts files:

import { version } from '../../package.json';
Enter fullscreen mode Exit fullscreen mode

However in Angular 12 you get an error:

Error: Should not import the named export 'version' (imported as 'version') from default-exporting module (only default export is available soon)


export const environment = {
  VERSION: require('../../package.json').version,
Enter fullscreen mode Exit fullscreen mode

And there is a good chance you will need to add this to your

"types": [ "node" ]
Enter fullscreen mode Exit fullscreen mode


Top comments (0)

Build Anything...

Use any Linode offering to create something for the DEV x Linode Hackathon 2022. A variety of prizes are up for grabs, inculding $1,000 USD. 👀

Join the Hackathon <-