Anyul Rivas Anyul Rivas - 1 month ago 6
React JSX Question

display the current npm version of my NodeJs app

I just want to display the version value of my package.json file within the footer of my app, but have no idea how to do that. I've read you could access those properties with process env object. Is it correct?

Answer

If you're running your app within NodeJs, you can access it by doing

process.env.npm_package_version

With ES6, you can also do

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