Before building applications with Node.js, we need to install it and set up our environment. In this article, you will learn how to install Node.js and run your very first program.
1. Downloading Node.js
Download the LTS (Long Term Support) version for stability.
- LTS → Stable
- Current → Latest features
2. Installing Node.js
- Open installer
- Click Next
- Accept license
- Finish
npm is installed automatically.
3. Verifying Installation
node -v
npm -v
Output:
v20.x.x
10.x.x
10.x.x
4. First Program
console.log("My first Node.js program");
5. Run Program
node app.js
Output:
My first Node.js program
6. What Happened?
- Node executed JS file
- V8 converted to machine code
- Output printed
7. Using REPL
node
2 + 2
Output: 4
8. Mistakes
- Node not recognized
- Wrong folder
- Wrong extension
Conclusion
Your system is ready for Node.js development 🚀
Tags
NodeJS