首页 > 解决方案 > 纱线命令未设置或无法运行 Linux Mint 18.2 Cinnamon

问题描述

因此,我的纱线已过时(1.5.1)这一事实一直存在问题。

我非常想升级,但没有任何答案对我有帮助。所以然后我去了,我以为我在 npm 和 apt 上都卸载了 yarn。yarn -v 仍然是 1.5.1。

我之前使用 npm 和 apt 更新了纱线,他们说他们已经更新到最新的纱线。但是,该命令显然不会转到他们的版本。

我做了 which yarn 响应是一些文件路径。我决定对它所在的整个文件夹进行核攻击。

这确实有效,但现在无论我如何重新安装纱线,我都无法让命令工作它指向旧路径: which yarn 然后继续抱怨它在那里找不到任何东西。

这是删除 cmdtest / yarn / 然后重新安装 yarn 的一点输出:

doom@doom-MacBookPro ~ $ which yarn
/usr/local/bin/yarn
doom@doom-MacBookPro ~ $ yarn
-bash: /home/doom/.yarn/bin/yarn: No such file or directory
doom@doom-MacBookPro ~ $ sudo apt remove cmdtest && sudo apt remove yarn && sudo apt install yarn
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Package 'cmdtest' is not installed, so not removed
The following packages were automatically installed and are no longer required:
  containerd libdb5.3++ libfltk1.1 libllvm4.0 libllvm4.0:i386 libllvm5.0
  libllvm5.0:i386 libmikmod3 libosmesa6 libportmidi0 libsdl-mixer1.2
  libsdl-ttf2.0-0 libsmpeg0 libtinyxml2.6.2v5 mokutil python-numpy
  python-pygame runc ttf-dejavu-core
Use 'sudo apt autoremove' to remove them.
0 upgraded, 0 newly installed, 0 to remove and 106 not upgraded.
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following packages were automatically installed and are no longer required:
  containerd libdb5.3++ libfltk1.1 libllvm4.0 libllvm4.0:i386 libllvm5.0
  libllvm5.0:i386 libmikmod3 libosmesa6 libportmidi0 libsdl-mixer1.2
  libsdl-ttf2.0-0 libsmpeg0 libtinyxml2.6.2v5 mokutil python-numpy
  python-pygame runc ttf-dejavu-core
Use 'sudo apt autoremove' to remove them.
The following packages will be REMOVED:
  yarn
0 upgraded, 0 newly installed, 1 to remove and 106 not upgraded.
After this operation, 4 596 kB disk space will be freed.
Do you want to continue? [Y/n] y
(Reading database ... 387271 files and directories currently installed.)
Removing yarn (1.10.1-1) ...
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following packages were automatically installed and are no longer required:
  containerd libdb5.3++ libfltk1.1 libllvm4.0 libllvm4.0:i386 libllvm5.0
  libllvm5.0:i386 libmikmod3 libosmesa6 libportmidi0 libsdl-mixer1.2
  libsdl-ttf2.0-0 libsmpeg0 libtinyxml2.6.2v5 mokutil python-numpy
  python-pygame runc ttf-dejavu-core
Use 'sudo apt autoremove' to remove them.
The following NEW packages will be installed:
  yarn
0 upgraded, 1 newly installed, 0 to remove and 106 not upgraded.
Need to get 0 B/796 kB of archives.
After this operation, 4 596 kB of additional disk space will be used.
Selecting previously unselected package yarn.
(Reading database ... 387254 files and directories currently installed.)
Preparing to unpack .../archives/yarn_1.10.1-1_all.deb ...
Unpacking yarn (1.10.1-1) ...
Setting up yarn (1.10.1-1) ...
doom@doom-MacBookPro ~ $ yarn -v
-bash: /home/doom/.yarn/bin/yarn: No such file or directory
doom@doom-MacBookPro ~ $ 

在我的 .bashrc

export PATH="$HOME/.yarn/bin:$HOME/.config/yarn/global/node_modules/.bin:$PATH"

一些额外的信息:

doom@doom-MacBookPro ~ $ whereis yarn
yarn: /usr/bin/yarn /usr/local/bin/yarn /usr/share/yarn
doom@doom-MacBookPro ~ $ yarn -v
-bash: /home/doom/.yarn/bin/yarn: No such file or directory

非常感谢您抽出宝贵的时间,我真的希望有人比我更清楚该做什么。

我怀疑在某个地方设置了命令部分,以便它强制指向特定路径...

如果安装设置命令,而不是手动执行此操作,我真的更喜欢,因为这似乎是其他人的行为方式就像他们的纱线一样。

编辑

所以就在我开始工作之前,我确实输入了这个:

doom@doom-MacBookPro ~ $ yarn -v
-bash: /home/doom/.yarn/bin/yarn: No such file or directory
doom@doom-MacBookPro ~ $ man yarn
No manual entry for yarn
See 'man 7 undocumented' for help when manual pages are not available.
doom@doom-MacBookPro ~ $ export PATH="$PATH:$(yarn global bin)"
-bash: /home/doom/.yarn/bin/yarn: No such file or directory
doom@doom-MacBookPro ~ $ yarn global
yarn global v1.10.1
error Invalid subcommand. Try "add, bin, dir, ls, list, remove, upgrade, upgrade-interactive"
info Visit https://yarnpkg.com/en/docs/cli/global for documentation about this command.

然后我真的做到了:

doom@doom-MacBookPro ~ $ yarn global -v
1.10.1
doom@doom-MacBookPro ~ $ cd Desktop/
doom@doom-MacBookPro ~/Desktop $ cd Rails
doom@doom-MacBookPro ~/Desktop/Rails $ yarn -v
1.10.1

所以不知何故它现在正在工作。不确定,但很高兴。

标签: npmyarnpkgaptlinux-mint

解决方案


尝试使用 sudo 运行命令


推荐阅读