Get Module Version in Node.js

• 1 min read

Here’s how to extract the version number from your package.json file. I use this to quickly verify that my current Nodejitsu snapshot is up to date.

// Require package.json like a regular module
var packageInfo = require('./package.json');

// Do something with the version
console.log('VERSION: ' + packageInfo.version);

Happy coding.

If you enjoyed this tutorial, please consider sponsoring my work on GitHub 🤗

Be the first to cheers
Now look what you've done 🌋
Stop clicking and run for your life! 😱
Uh oh, I don't think the system can't handle it! 🔥
Stop it, you're too kind 😄
Thanks for the love! ❤️
Thanks, glad you enjoyed it! Care to share?
Hacker News Reddit

×

Recommended Posts ✍🏻

See All »
• 3 min read
✨ HTML Share Buttons
Read Post »
• 3 min read
🚅 Next Stop, Yaak
Read Post »
• 4 min read
💻 Wait for User to Stop Typing, in JavaScript
Read Post »