To install Node.js in windows, open the MSDOS command promt terminal as administrator and execute the following commands in this order. Please read the commands before executing them as you may get the same errors.
node -v
npm cache clean -f
node -v
OK, hopefully you will not get any errors, but if you do, this is how you troubleshoot.
You might get the following error or something similar:
PS C:\WINDOWS\system32> npm install -g n
npm ERR! code EBADPLATFORM
npm ERR! notsup Unsupported platform for [email protected]: wanted {"os":"!win32","arch":"any"} (current: {"os":"win32","arch":"x64"})
npm ERR! notsup Valid OS: !win32
npm ERR! notsup Valid Arch: any
npm ERR! notsup Actual OS: win32
npm ERR! notsup Actual Arch: x64
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\$USER\AppData\Roaming\npm-cache\_logs\2020-04-27T21_30_55_059Z-debug.log
If you get this error, you will have to download the .msi file form the https://nodejs.org/en/ website. After you have downloaded and install it, it will automatically upgrade your node.js version. you can confirm your current version of node with the following command: node -v