Your support helps keep this blog running! Secure payments via Paypal and Stripe.
Lately, I have been working on the Vue.js project. I installed NodeJS and NPM before, but now I want to update them to the latest version. This post will show how.
On modern setups, npm and npx are tied to Node.js:
npx
is bundled insidenpm
.npm
versions are released in step with newer Node.js versions.
So if your Node.js is too old, the newest npm
version simply won’t run on it. That’s why the update failed.
Note
👉 Update Node.js first (to the latest LTS), and npm
/npx
will automatically update to versions that are fully compatible.
Table of Contents
Update npm (Node Package Manager)
If you just want to update only npm
, follow the steps below.
- Check your current npm version
Open your terminal and run:npm -v
- Install the latest npm version globally
npm install -g npm@latest
- Verify the update
Run the version check again to confirm the upgrade:npm -v
Update Node.js
If you are trying to update npm and the update fails, you will need to update NodeJS instead.
On Windows
- Simply go to the official Node.js website and download the LTS (.msi installer).
- Run the installer—it’ll detect and upgrade your existing installation.
- After installation, verify with:
node -v
On macOS or Linux
- Check your Node.js version:
node -v
- Install the
n
module globally using npm:sudo npm install -g n
- Upgrade Node.js using
n
:- To get the latest version:
sudo n latest
- For the most stable release:
sudo n stable
- To get the latest version:
- Confirm the update:
node -v
Hope this helps! If you’d like to show your support, you can buy me a coffee.
Your support helps keep this blog running! Secure payments via Paypal and Stripe.