Before you start throwing confetti, check your installation. Type node --version in the terminal. If you see something like v20.x.x, you’re golden. That number means Node is alive, awake, and ready to run your code.
Don’t forget about npm, Node’s package manager—it’s like an app store for JavaScript libraries. Run npm --version to see that too. If it shows a version, you’ve got the full duet: Node and npm, partners in crime.
How to Install Node.js on Ubuntu - Pi My Life Up
Feeling brave? Type node to open the interactive shell. Then type console.log("Hello from the terminal!"); and press Enter. Did it print? Congratulations—you just ran JavaScript on your Ubuntu system. How cool is that?
What If You Want Two Versions? (The Superpower Move)
Sometimes, you need a specific Node version for an old project. That’s where nvm (Node Version Manager) comes in. It’s like having a wardrobe of Node versions—one day you’re v18, the next you’re v22. Install it with a quick curl command (search “nvm install script” for the latest line).
With nvm, you can switch versions on the fly. Type nvm install lts for the latest stable, or nvm use 16 if you’re feeling nostalgic. It’s the ultimate hack for developers who love flexibility. And yes, it pairs beautifully with Ubuntu.