Reputation:
I installed Yarn on my Ubuntu 16.04 server.
Setup flow:
curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add -
echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list
and then
sudo apt-get update && sudo apt-get install yarn
Apparently it doesn't end with an error:
...
Processing triggers for libc-bin (2.23-0ubuntu11) ...
But when I run yarn --version
I get this error
root@AMS-148750:~# yarn --version
/usr/share/yarn/lib/cli.js:46083
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)
Please let me know how to fix it. Thank you in advance.
Upvotes: 2
Views: 2472
Reputation: 289
There could be another reason for that. Your nodejs version is very old. You just need to upgrade your nodejs with below command (using npm).
sudo npm install -g n
sudo n stable
This will upgrade to latest stable version.
Worked for me.
Upvotes: 1
Reputation: 1091
I've got such error because I'm using nvm
but I didn't install any node version :stuck_out_tongue_closed_eyes:
nvm list
N/A
iojs -> N/A (default)
node -> stable (-> N/A) (default)
unstable -> N/A (default)
Just install node version which you need, for example
nvm install 13.3.0
Upvotes: 0
Reputation: 1968
that is because your node version is incompatible with yarn.Check your node version with node -version
if you have an older version of node then upgrade it to latest version by using:
curl -sL https://deb.nodesource.com/setup_10.x | sudo -E bash -
apt-get install -y nodejs
Upvotes: 3
Reputation: 426
This looks like a too old nodejs version for the version of yarn installed from the repo. Please check the requirements for the yarn version you installed and make sure your server fulfills them.
Upvotes: 2