【发布时间】:2016-10-13 20:17:29
【问题描述】:
我正在尝试yarn self-update 命令以查看它是如何工作的,但它没有更新 Yarn 版本,而是像这样抛出 OAuth 错误
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.
有谁知道这是为什么以及需要做些什么来解决这个问题?根据文档here,此命令没有任何此类 OAuth 依赖项,恕我直言,它也不应该。
看起来已经有一个 PR here
编辑:进一步的研究表明这是一个已知的bug with Yarn。但是仍然没有解决方案。如果将修复程序作为新版本推出,那将是一个奇怪的 catch22,但由于命令失败,用户无法更新。一种可能的解决方案是yarn self-update [tag] 而不是yarn self-update,但这仍然是一个错误。*
编辑:我意识到还有另一种解决方法
yarn version
yarn version <version-number>
【问题讨论】:
-
yarn version 用于更新 package.json 中的版本,而不是 yarn 本身。
-
实际上没有。如果不带参数使用,version可以用来更新yarn的版本
-
我刚刚又试了一次,但是当不带参数使用时,您会显示软件包的版本,并提示您输入新版本。
-
此外,当您在没有 package.json 的目录上尝试
yarn version时,会显示此消息:Couldn't find a package.json (or bower.json)
标签: npm runtime-error oauth2 yarnpkg