Skip to content

Instantly share code, notes, and snippets.

@shreshthmohan
Created August 15, 2022 15:53
Show Gist options
  • Save shreshthmohan/4a802ce3e32dab67249bf5ced3789bf9 to your computer and use it in GitHub Desktop.
Save shreshthmohan/4a802ce3e32dab67249bf5ced3789bf9 to your computer and use it in GitHub Desktop.
Get package version in JS (ES6+)
// 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