atf.sgf
atf.sgf

Reputation: 494

How to solve unexpected token issue in yarn installation

I install yarn on my server without any error, when I run yarn -v I get this error I think the yarn did not install properly, what is wrong?

/usr/share/yarn/lib/cli.js:46100
  let {
      ^

SyntaxError: Unexpected token {
    at exports.runInThisContext (vm.js:53:16)
    at Module._compile (module.js:374:25)
    at Object.Module._extensions..js (module.js:417:10)
    at Module.load (module.js:344:32)
    at Function.Module._load (module.js:301:12)
    at Module.require (module.js:354:17)
    at require (internal/module.js:12:17)
    at Object.<anonymous> (/usr/share/yarn/bin/yarn.js:24:13)
    at Module._compile (module.js:410:26)
    at Object.Module._extensions..js (module.js:417:10)

Upvotes: 7

Views: 19951

Answers (2)

Kaiser
Kaiser

Reputation: 21

Got same issue. The problem was that my PC has crashed while yarn install. Resolved with:

yarn cache clean

Upvotes: 1

koko-js478
koko-js478

Reputation: 2021

The error is caused by the old version of nodejs (usually lower than v6).

  • First install the latest stable version of nodejs or more recent version than you are using now.
# Using Ubuntu
curl -sL https://deb.nodesource.com/setup_lts.x | sudo -E bash -
sudo apt-get install -y nodejs

# Using Debian, as root
curl -sL https://deb.nodesource.com/setup_lts.x | bash -
apt-get install -y nodejs

https://github.com/nodesource/distributions/blob/master/README.md

  • Then install yarn:

https://yarnpkg.com/en/docs/install#debian-stable

Upvotes: 12

Related Questions