Issue
I am trying to get the "version" from the package.json
is nextjs application.
I have tried process.env.npm_package_version
like in node application but it's returning undefined
.
Solution
You can use process.env.npm_package_version
only if you installed the package package_vars
before (see: https://docs.npmjs.com/cli/v6/using-npm/scripts#packagejson-vars)
But the simplest way in your case is to import your package.json
file (which is a mere .json
file) like this:
const { version } = require('./package.json');
console.log(version);
Answered By - Volonté du Peuple
Answer Checked By - - Gilberto Lyons (ReactFix Admin)