Import version from package.json

Sami C.
1 min readApr 9, 2019

--

Today I made the decision to add versioning to our application. What I really wanted was to get the version number of the package json and render it on a html page.

If you’re using typescript 2.9+

Simply import the version from the package json like this:

import {Version} from '../package.json';

And do not to forget to add theresolveJsonModule inside your tsconfig.json

"resolveJsonModule": true

Thanks for reading and happy coding!

--

--

Sami C.
Sami C.

Written by Sami C.

Freelance Software Engineer

Responses (1)