How to check version in Node.js? Check Node version from command line
You might use node.js for many of your projects. But do you know how to find the version of node.js? If not, you are in the right place.
Software developers are working every day on adding new features, fixing bugs & patching vulnerabilities to their software. This is because no software is perfect on the very first release. So they roll out various releases, and to differentiate between them, they use version numbers.
Like other software, Node.js too has a lot of versions. Where can we find them? Just visit github.com/nodejs/node/releases and click on tags.
As of now, it seems like v18.8.0 is the latest version.
Knowing the version of your node is important because:
- You might be working on a project which requires a different node version. In that case to make sure everything works perfectly on your end you have to match that particular node version.
- If you are stuck at an older version of node, it might be that your project has some vulnerabilities or security risks. You might also be missing out on some of the improvements that may be implemented in the recent versions. So, you can check if your version is the latest. If not you should update your node.js.
What is Node.js?
Node.js is a JavaScript runtime built on Chrome’s V8 JavaScript engine. It’s used for developing server-side applications and for executing JavaScript code outside of a browser.
Read this blog “What is Node.js? – Introduction” to know more about Node.js.
Initial Setup
If you don’t have Node.js installed on your local machine, don’t worry, Codedamn got you covered.
If you already have Node.js installed on your local machine, then you can skip this section.
So, let’s start:
1. Visit the Codedamn Playground and select Node.js.
2. Give your playground a name. I will set it to “check-node-version”. Now, click on “Create Playground”.
3. It should open up a web IDE with a terminal at the bottom. Press Ctrl+C
to stop the current process that is running.
Now you have a system with Node.js installed.
Determining the version of Node.js
It’s actually very simple. And you don’t even have to remember anything.
Most of the command line tools have a help
flag. Running the command with this flag gives us a manual on how to use the tool. So just type node --help
and you will get a list of all the available flags.
node --help
There will be a lot of information, but all we need to search for is “version”. Right at the bottom, you will find the flag for the version.
So, the flag to get the version is --version
or -v
. So just type node -v
and you will get the version of Node.js you are using.
$ node -v
v16.17.0
or,
$ node --version
v16.17.0
So, this means that I am using version 16.17.0 of Node.js. This might be different from the version you are using.
Even though the steps mentioned in this article are very specific to Node.js, they can still be applied to most of the command line tools.
Conclusion
So, in this article, we learned the importance of versions and why we should keep our software updated. We learned some tips on how to find the relevant flags of a command. To find the version of the node that we are using, we use the flag --version or -v
.
Sharing is caring
Did you like what Arnab Sen wrote? Thank them for their work by sharing it on social media.
No comments so far
Curious about this topic? Continue your journey with these coding courses: