SyntaxError: Block-scoped declarations (let, const, function, class) not yet supported outside strict mode

What I wanted to do

I want to know my npm version.

What happened instead

Error happened.

Reproduction steps

$ brew install node@8

==> Pouring node@8-8.15.1.mojave.bottle.tar.gz
==> Caveats
node@8 is keg-only, which means it was not symlinked into /usr/local, because this is an alternate version of another formula.

$ npm --version

3.10.6

$ /usr/local/Cellar/node@8/8.15.1/bin/npm --version

/usr/local/Cellar/node@8/8.15.1/lib/node_modules/npm/bin/npm-cli.js:85
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:968:3

Platform Info

$ node -p process.platform
darwin

(macOS Mojave 10.14.4 with Xcode 10.2)

I suspect the HomeBrew install did not activate that version of node for some reason, and your active version of node was not compatible with the Cellar version of npm. Check what is active with one of:

npm --versions
node --version

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.