找不到来自安装了 yarn 的包的命令?

Commands from packages installed with yarn not found?

我用 yarn 全局安装了 vue-cli,但是 vue 给出了 "command not found" 错误。为什么会发生这种情况,我该如何解决?

一些有趣的调试信息:

$ yarn global list
yarn global v1.7.0
info "qbrt@0.2.5" has binaries:
   - qbrt
info "vue-cli@2.9.6" has binaries:
   - vue
   - vue-init
   - vue-list
info "webpack@4.16.0" has binaries:
   - webpack
Done in 0.56s.
$ ls $(yarn global bin)
$

如您所见,我的二进制文件目录似乎是空的...

我发现二进制文件在其他地方结束了。

$ yarn global bin
/home/username/.npm-packages/bin
$ ls ~/.yarn/bin
acorn   errno        handlebars  _metalsmith   rimraf       sha.js        uglifyjs  vue-init  win-fork
atob    esparse      json5       miller-rabin  seek-bunzip  sshpk-conv    uid       vue-list  win-line-endings
cake    esvalidate   js-yaml     mkdirp        seek-table   sshpk-sign    uuid      webpack   win-spawn
coffee  extract-zip  metalsmith  qbrt          semver       sshpk-verify  vue       which

奇怪,但将 ~/.yarn/bin 添加到我的 $PATH 中修复了它。