Travis Heeter
Travis Heeter

Reputation: 14084

SyntaxError when trying to do anything in npm

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:

Upvotes: 1

Views: 1526

Answers (1)

Travis Heeter
Travis Heeter

Reputation: 14084

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.

Upvotes: 2

Related Questions