How do I update npm and Node.js to the latest versions?

I recently installed Node.js and npm, but I realized both are outdated.

I’d like to know the correct way to update npm and Node.js to their latest stable versions without breaking my existing setup.

Should I uninstall and reinstall them, or is there a cleaner upgrade path?

Also, what’s the recommended way to upgrade all globally installed Node.js modules after updating?

Appreciate any tips or commands that simplify the update process!