Created
August 15, 2022 15:53
-
-
Save shreshthmohan/4a802ce3e32dab67249bf5ced3789bf9 to your computer and use it in GitHub Desktop.
Get package version in JS (ES6+)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// default import from 'packageName/package.json' | |
// where 'package' is installed to node_modules | |
// used 'tailwindcss' as a real-world example below | |
import packageJson from 'tailwindcss/package.json' | |
const version = packageJson.version | |
console.log(version) // 3.1.8 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment