repro-detect-version
v1.0.0
Published
Expose the Node.js version used to install the package.
Maintainers
Readme
repro-detect-version
Expose the Node.js version used when the package was installed.
API
import { getVersion } from "repro-detect-version";
console.log(getVersion());getVersion() returns the value captured by the package postinstall script, not the current runtime process.version.
How it works
- During install,
postinstallrunsscripts/write-installed-version.js. - That script writes
process.versiontodata/installed-node-version.txt. getVersion()reads that file and returns it.
Important
If install scripts are disabled (for example npm install --ignore-scripts), version metadata is not generated and getVersion() throws an error telling you to reinstall.
