LoginSignup
0
0

More than 5 years have passed since last update.

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

Posted at

久しぶりにTerminalを起動してみたら直後に下記エラーが表示された。

/Users/xxx/.nvm/versions/node/v4.6.0/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:974:3
nvm is not compatible with the npm config "prefix" option: currently set to ""
Run `npm config delete prefix` or `nvm use --delete-prefix v4.6.0 --silent` to unset it.

結論からいうとnvmで指定しているnpmのデフォルトバージョンが違っているから発生していた。

$ nvm ls
         v4.6.0  
         v6.2.0  
        v8.11.4  

defaultがv4.6.0になっていたので、v6.2.0に変更したら表示されなくなった。

$ nvm alias default v6.2.0
default -> v6.2.0

感想

Node.jsは主にプライベートで触っているだけなので、ついていけてません。
Webの進化のスピードには驚いています。

参照

nvmでnode.jsの環境をつくる。 - Qiita

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0