Skip to content

Instantly share code, notes, and snippets.

@benjamincharity
Last active December 4, 2017 12:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save benjamincharity/691106580b4e4b592a6a8f6a3831ec30 to your computer and use it in GitHub Desktop.
Save benjamincharity/691106580b4e4b592a6a8f6a3831ec30 to your computer and use it in GitHub Desktop.
From: https://stackoverflow.com/a/41299263/722367 It's worth to mentioned that if someone encounter on error "Cannot find name require" after applying your solution then needs to add "node" type inside "types" property in tsconfig.app.ts file. << "types": ["node"] >>.
const { version: appVersion } = require('../../package.json')
// this loads package.json
// then you destructure that object and take out the 'version' property from it
// and finally with ': appVersion' you rename it to const appVersion
@Component({
selector: 'stack-overflow',
templateUrl: './stack-overflow.component.html'
})
export class StackOverflowComponent {
public appVersion
constructor() {
this.appVersion = appVersion
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment