1

I am trying to upgrade nodejs to latest version in my machine. I am getting below error after executing below commands through npm.

npm install -g n

This gave error as below

npm ERR! code EBADPLATFORM
npm ERR! notsup Unsupported platform for n@2.1.12: 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

Then I found this question and executed below commands.

npm install --global --production npm-windows-upgrade
npm-windows-upgrade --npm-version latest

I am getting below error in node command prompt

C:\Users\myName\AppData\Roaming\npm\node_modules\npm-windows-upgrade\src\upgrader.j
s:26
  async ensureInternet () {
        ^^^^^^^^^^^^^^
SyntaxError: Unexpected identifier
    at createScript (vm.js:56:10)
    at Object.runInThisContext (vm.js:97:10)
    at Module._compile (module.js:542:28)
    at Object.Module._extensions..js (module.js:579:10)
    at Module.load (module.js:487:32)
    at tryModuleLoad (module.js:446:12)
    at Function.Module._load (module.js:438:3)
    at Module.require (module.js:497:17)
    at require (internal/module.js:20:19)
    at Object.<anonymous> (C:\Users\HP2\AppData\Roaming\npm\node_modules\npm-win
dows-upgrade\bin\npm-windows-upgrade.js:8:16)

Could anyone please help on this?

Current version npm 6.9.0 Current Version node v6.10.3

Niju
  • 487
  • 1
  • 9
  • 18
  • Possible duplicate of [Upgrading Node.js to latest version](https://stackoverflow.com/questions/10075990/upgrading-node-js-to-latest-version) From the accepted answer "just reinstall node from the .msi in Windows from the node website. " – 1565986223 Mar 24 '19 at 10:50
  • For windows, just download the installer from nodejs.org – Thamaraiselvam Mar 25 '19 at 07:15

2 Answers2

1

Just try downloading and installing the latest version from the NodeJS website directly. Or use as package manager like Chocolatey and download and update NodeJS via Powershell or your own script.

suckerp
  • 310
  • 1
  • 4
  • 11
1

First thing to note is use powershell as administrator

Please check node version,

For Node versions lower than v8.0, please use

 npm-windows-upgrade@5.0.0

For Node versions lower than v6.0, please use

 npm-windows-upgrade@4.1.1

For Node versions lower than v4.0, please use

 npm-windows-upgrade@3.1.1

My node version was 6.9.5. I tried

 npm install --global --production npm-windows-upgrade@5.0.0
Ali Akbar
  • 370
  • 3
  • 9