Environment variables npm_package_name npm_package_version not available from package.json file
gitSambhal opened this issue · 3 comments
gitSambhal commented
What version of pkg are you using?
5.8.1
What version of Node.js are you using?
v18.16.0
What operating system are you using?
Windows
What CPU architecture are you using?
arm64
What Node versions, OSs and CPU architectures are you building for?
node18-win-x64
Describe the Bug
The following environment variables are not available while running as binary:
- npm_package_name
- npm_package_version
Expected Behavior
These environment variables should be present having the respective values from package.json file.
To Reproduce
console.log('process env', process.env);
huangganggui commented
I got same question.
Do you have any solution? @gitSambhal
huangganggui commented
Hi @gitSambhal
I got a solution. And share for you. Try it:
var pjson = require('../../package.json');
console.log(pjson.version);
gitSambhal commented
Hi @huangganggui,
Thanks for sharing. I had used somthing similar.