Get the current version of a module.
Use the package manager npm to install it.
npm install which-version
Import the method and use,
const getVersion = require("which-version").getVersion;
getVersion();
// => 1.1.0
- To get the name as well as version, use
getInfo
method
const { name, version } = require("which-version").getInfo();
If you are inside a module or project, simply find the version in command line using npx
,
npx which-version
//=> module-name :: 1.1.0