0

I was trying to update my Node Package Manager using g npm install npm@latest -g in the terminal but when I tried to check if it was updated using npm --version or npm -v or even npm install, I get the following error:

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:387:25)
at Object.Module._extensions..js (module.js:422:10)
at Module.load (module.js:357:32)
at Function.Module._load (module.js:314:12)
at Function.Module.runMain (module.js:447:10)
at startup (node.js:139:18)
at node.js:999:3

I had version 5.0.3 for NPM and now I can't run any npm commands. Can someone please help me remedy this error by uninstalling this latest version or anything to get this version to work.

  • What is your Node version at? I think you need to bump it up. – Tom Con May 23 '18 at 23:11
  • 1
    Why not reinstall Node and NPM? What system are you on? Would recommend [node version manager](https://github.com/creationix/nvm#installation) to stay up to date with node versions. – rassa45 May 23 '18 at 23:11
  • @TomCon my system is Mac OS High Sierra and my node manager was at 5.0.3. I don't know what my version is currently at because now whenever I run npm --version I get that error above. – Stephanie Cray May 23 '18 at 23:33
  • @ytpillai my system is Mac OS High Sierra and my node manager was at 5.0.3. I don't know what my version is currently at because now whenever I run npm --version I get that error above. – Stephanie Cray May 23 '18 at 23:33
  • @StephanieCray Yup, that's what I thought. there's a new flavour of Javascript called ES6 (and above) that uses certain keywords that aren't found in your Node version. the new NPM uses these keywords but your older version of Node can't interpret them. Best option is to uninstall and get the latest version. – rassa45 May 23 '18 at 23:35
  • Possible duplicate of [Block-scoped declarations not yet supported outside strict mode - Laravel Mix](https://stackoverflow.com/questions/41960142/block-scoped-declarations-not-yet-supported-outside-strict-mode-laravel-mix) – rassa45 May 23 '18 at 23:38
  • Thanks @ytpillai, updating node was the way to go. – Stephanie Cray May 24 '18 at 15:33
  • In order to fix the error and set my node package manager to 5.6.0, I didn't have to uninstall node. All I did was go to https://nodejs.org/en/ and download it there, restart my computer, and type in the terminal to check my version npm -v. – Stephanie Cray May 24 '18 at 15:41
  • Alright, but now you might have two Node versions installed assuming you installed from binary or source. That's what I was trying to help you avoid. – rassa45 May 24 '18 at 17:07

1 Answers1

0

Block-scoped declarations not yet supported outside strict mode - Laravel Mix, check out this StackOverflow answer. The solution is pretty much to update Node, but I'll explain why. There's a new flavour of Javascript called ES6 (and above) that uses certain keywords that aren't found in your Node version. the new NPM uses these keywords but your older version of Node can't interpret them. Best option is to uninstall and get the latest version.

rassa45
  • 3,482
  • 1
  • 29
  • 43