I found this piece of code worked for me:
nvm install node
https://www.freecodecamp.org/news/how-to-update-node-and-npm-to-the-latest-version/