如何切换纱线版本/检查纱线的安装位置?

时间:2019-01-17 17:53:12

标签: node.js npm homebrew yarnpkg

您好,我尝试了以下操作:

yarn -v => 1.3.2

brew list yarn =>

/usr/local/Cellar/yarn/1.13.0/bin/yarn
/usr/local/Cellar/yarn/1.13.0/bin/yarnpkg
/usr/local/Cellar/yarn/1.13.0/libexec/bin/ (5 files)
/usr/local/Cellar/yarn/1.13.0/libexec/lib/ (2 files)
/usr/local/Cellar/yarn/1.13.0/libexec/package.json

brew switch yarn 1.13.0 =>

Cleaning /usr/local/Cellar/yarn/0.24.6
Cleaning /usr/local/Cellar/yarn/1.7.0
Cleaning /usr/local/Cellar/yarn/1.13.0
Cleaning /usr/local/Cellar/yarn/1.12.3
2 links created for /usr/local/Cellar/yarn/1.13.0

但是yarn -v仍然=> 1.3.2

它也不在npm上 npm list -g --depth=0 =>

/Users/johndoe/.nvm/versions/node/v9.11.1/lib
├──  error: ENOENT: no such file or directory, stat '/Users/johndoe/.nvm/versions/node/v9.11.1/lib/node_modules/@particles/dashboard
├──  error: ENOENT: no such file or directory, stat '/Users/johndoe/.nvm/versions/node/v9.11.1/lib/node_modules/@particles/navigation-tiers
├── create-react-native-app@1.0.0
├── exp@51.4.0
├──  error: ENOENT: no such file or directory, stat '/Users/johndoe/.nvm/versions/node/v9.11.1/lib/node_modules/my-procore
├── node-gyp@3.8.0
├── npm@5.6.0
└── react-native-cli@2.0.1

1 个答案:

答案 0 :(得分:0)

您可能想检查实际,而不是使用yarn命令在外壳程序上执行的which命令

$ which yarn
/usr/local/bin/yarn
$ ls -l /usr/local/bin/yarn
lrwxr-xr-x  1 hanxue  admin  30 Jan 17 01:59 /usr/local/bin/yarn -> ../Cellar/yarn/1.13.0/bin/yarn

您可能正在执行nvm安装的yarn的其他版本。我不建议同时使用nvmbrew。两者都是在多个版本的节点之间安装和切换的绝佳选择,但同时使用它们可能会引起冲突和混乱。