yarnpkg / yarn

The 1.x line is frozen - features and bugfixes now happen on https://github.com/yarnpkg/berry
https://classic.yarnpkg.com
Other
41.44k stars 2.72k forks source link

"yarn -v" fail with node 4.9.1 yarn 1.13.0 #6900

Open GalNoga opened 5 years ago

GalNoga commented 5 years ago

bug report:

current behavior: when running "npm --global install" in order to upgrade to latest yarn version (1.13.0) using node version 4.9.1 and then running 'yarn -v' we get the following error:

/usr/local/lib/node_modules/yarn/lib/cli.js:45726
  let {
      ^

SyntaxError: Unexpected token {
    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 Module.require (module.js:353:17)
    at require (internal/module.js:12:17)
    at Object.<anonymous> (/usr/local/lib/node_modules/yarn/bin/yarn.js:24:13)
    at Module._compile (module.js:409:26)
    at Object.Module._extensions..js (module.js:416:10)

expected behavior: as behaves when using previous yarn versions (e.g 1.12.3): npm --global install yarn npm --global install yarn@1.12.3 yarn -v should succeed with no errors.

alvarosdev commented 5 years ago

Same error, Reinstalling with nodesource/distributions worked for me

BrynM commented 5 years ago

Ran into the same issue today. Thanks for mentioning the working version. That helped me with an interim fix.

Sx3 commented 5 years ago
/usr/share/yarn/lib/cli.js:45726
  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)

On ubuntu 16.04

Sx3 commented 5 years ago

https://github.com/yarnpkg/yarn/issues/6914#issuecomment-454124927

tolmasky commented 5 years ago

The engines field in the package.json reports ">= 4.0.0". This version should be removed from npm and a new version should be published with the correct engines field, and probably a major version bump since it is a breaking change to drop support for a major version of node.

marcinprzybysz86 commented 5 years ago

same here. Centos 7, npm 3.8.3, node 5.1.0, yarn 1.12 . Downgraded to 1.7 and gonna see.

digimix commented 5 years ago

Make sure your user has access to Node + NPM. For Ubuntu, try installing yarn from apt-get as per the Yarn docs for the Yarn Debian Stable Install. I triggered this issue but performed the troubleshooting above and resolved it. Ubuntu 16.04, Node v8.11.3, NPM 5.6.0, Yarn 1.13.0

simonsigre commented 5 years ago

Alternatively as a work around you can also just remove the package and install an older version (I was getting the same errors above listed in the nightlies)

wget https://nightly.yarnpkg.com/debian/pool/main/y/yarn/yarn_1.9.0-20180719.1538_all.deb
sudo apt install ./yarn_1.9.0-20180719.1538_all.deb 
i-fail commented 5 years ago

The comment in #6914 solved the problem by updating Node to v10:

curl -sL https://deb.nodesource.com/setup_10.x | sudo -E bash -
apt-get install -y nodejs
stvenyin commented 5 years ago

succesful,thanks! mactype uninstall is a problem

andreasneuber commented 5 years ago

In case you are using Ansible with packages from Ansible Galaxy.. After also having above error - this playbook below solved yarn installing perfectly for me:

---
- hosts: all
  roles:
  - geerlingguy.nodejs
  - ocha.yarn
  become: yes
  become_user: root
  become_method: sudo