1

I came back to a Win10 PC I haven't used in a while. First thing, I tried to update npm with

> npm i npm -g

I got back this:

added 290 packages, removed 250 packages and updated 37 packages in 38.815s
   ╭─────────────────────────────────────╮
   │                                     │
   │   Update available 5.0.0 → 6.4.1    │
   │     Run npm i -g npm to update      │
   │                                     │
   ╰─────────────────────────────────────╯

Then, I tried to run npm i -g npm and got:

     let notifier = require('update-notifier')({pkg})
      ^^^

SyntaxError: Block-scoped declarations (let, const, function, class) not yet supported outside strict mode
    at exports.runInThisContext (vm.js:53:16)
    at Module._compile (module.js:373:25)
    at Object.Module._extensions..js (module.js:416:10)
    at Module.load (module.js:343:32)
    at Function.Module._load (module.js:300:12)
    at Function.Module.runMain (module.js:441:10)
    at startup (node.js:139:18)
    at node.js:974:3

Now when I try to do anything, I get that same error. In case you were wondering I was trying to update from npm 5.0.0 to 6.4.1.


Things I've tried

I Googled this error and found the following:

  • Update Node

    • Following these instructions I first tried to clear npm's cache with npm cache clean -f, but got the same SyntaxError.
    • The same instructions also say to do some stuff with nvm, which I don't have, so I tried to install it with npm i nvm -g, but same error.
  • use strict, even though I know this is for a program using node. I wanted to be sure I tried everything before posting a question.

    • '"use strict"' is not recognized as an internal or external command, operable program or batch file.
  • Fresh npm install of webpack.js is throwing Block-scope error but this didn't seem to apply to me because I'm not using Visual Studio, and I haven't done anything with babel or webpack or es6. I'm just trying to update npm.

Travis Heeter
  • 13,002
  • 13
  • 87
  • 129

1 Answers1

2

I couldn't find any answers so I decided to completely uninstall node and npm using these instructions: https://stackoverflow.com/a/20711410/1152809

Then I reinstalled node and everything works as expected.

Travis Heeter
  • 13,002
  • 13
  • 87
  • 129