13

I am trying out the yarn self-update command to see how it works, but instead of updating the Yarn version, it throws an OAuth error like so

yarn self-update
yarn self-update v0.15.1
error OAuth2 authentication requires a token or key & secret to be set
    at __dirname.authenticate (/Users/nikjohn/.nvm/versions/node/v6.4.0/lib/node_modules/yarn/node_modules/github/lib/index.js:334:23)
    at Object.<anonymous> (/Users/nikjohn/.nvm/versions/node/v6.4.0/lib/node_modules/yarn/lib/cli/commands/self-update.js:30:12)
    at next (native)
    at step (/Users/nikjohn/.nvm/versions/node/v6.4.0/lib/node_modules/yarn/node_modules/babel-runtime/helpers/asyncToGenerator.js:17:30)
    at /Users/nikjohn/.nvm/versions/node/v6.4.0/lib/node_modules/yarn/node_modules/babel-runtime/helpers/asyncToGenerator.js:35:14
    at new Promise (/Users/nikjohn/.nvm/versions/node/v6.4.0/lib/node_modules/yarn/node_modules/core-js/library/modules/es6.promise.js:191:7)
    at Object.<anonymous> (/Users/nikjohn/.nvm/versions/node/v6.4.0/lib/node_modules/yarn/node_modules/babel-runtime/helpers/asyncToGenerator.js:14:12)
    at Object.run (/Users/nikjohn/.nvm/versions/node/v6.4.0/lib/node_modules/yarn/lib/cli/commands/self-update.js:99:17)
    at run (/Users/nikjohn/.nvm/versions/node/v6.4.0/lib/node_modules/yarn/lib/cli/index.js:237:18)
    at config.init.then (/Users/nikjohn/.nvm/versions/node/v6.4.0/lib/node_modules/yarn/lib/cli/index.js:345:12)
info Visit http://yarnpkg.com/en/docs/cli/self-update for documentation about this command.

Does anybody know why this is and what needs to be done to resolve this? According to the docs here, this command does not have any such OAuth dependency and IMHO it shouldn't either.

Looks like there's a PR for this already here

Edit: Further research shows this is a known bug with Yarn. But a resolution is still not available. It would be a weird catch22 if the fix is pushed out as a new version, but users can't update because the command fails. One possible solution is yarn self-update [tag] instead of yarn self-update, but this remains a bug.*

Edit: I realized there's another workaround

yarn version
yarn version <version-number>
4

4 回答 4

15

用来npm -g install yarn更新它。我升级到了 yarn v0.16.0,现在yarn self-update似乎可以工作了。

于 2016-10-19T09:57:14.470 回答
11

首先使用以下命令删除 Yarn:

rm -rf ~/.yarn

然后再次安装它,使用这个命令(例如):

curl -o- -L https://yarnpkg.com/install.sh | bash
于 2016-10-23T20:27:02.327 回答
1

TL;博士

更新为≥0.16.0

Ubuntu

apt-get update ; apt-get install yarn

苹果系统

brew update ; brew upgrade

新PM

npm install -g yarn --update

解释

有这个问题0.15.0,并且调查它很多人添加了同样的问题。

$ yarn --version
0.15.0

阅读发行说明v0.16.0

修复自我更新(#676

所以只需更新:

yarn self-update
yarn self-update v0.16.0
success Yarn is already using the latest version.
Done in 0.69s.
于 2016-10-23T09:56:58.580 回答
-1
npm uninstall -g yarm 
npm cache clean
npm install -g yarm
于 2016-11-09T14:14:05.417 回答