upgrade or update nodejs

  1. Open a terminal window.

  2. Run the following command to update npm (Node Package Manager) to the latest version: npm install -g npm

  3. Check the currently installed version of Node.js by using the following command: node -v

  4. If you have Node.js version manager (nvm) installed, you can use it to upgrade Node.js. Otherwise, you can update Node.js directly with the following commands: npm cache clean -f npm install -g n n stable

  5. Verify the updated Node.js version by running: node -v

  6. If you encounter permission issues during the update, you may need to use sudo: sudo npm install -g n sudo n stable

  7. Confirm the updated Node.js version once again: node -v

  8. Restart your terminal to apply the changes.