gab*_*iso 10 linux shell terminal node.js
我昨天开始使用fish作为我的shell,今天我尝试使用yarn在终端中运行我的NextJs应用程序,并且tailwind给了我一个关于节点版本的错误。我检查了一下,然后发现当前版本是10.19.0。
\n在我的 zsh shell 中,我安装了 Node、npm 和 nvm,并且可以毫无错误地使用它们,但在我的 Fish shell 中,仅存在 Node。我尝试使用以下命令在终端中安装 nvm:
\ncurl -o- https://raw.githubusercontent.com/creationix/nvm/v0.31.4/install.sh | bash \nRun Code Online (Sandbox Code Playgroud)\n以下输出是:
\n=> nvm is already installed in /home/gabriel/.nvm, trying to update using git\n=> error: pathspec \'v0.31.4\' did not match any file(s) known to git\n\n=> Source string already in /home/gabriel/.profile\nmain: linha 293: /nvm.sh: Arquivo ou diret\xc3\xb3rio n\xc3\xa3o encontrado\n=> Close and reopen your terminal to start using nvm or run the following to use it now:\n\nexport NVM_DIR="/home/gabriel/.nvm"\n[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh" # This loads nvm\xe2\x8f\x8e \nRun Code Online (Sandbox Code Playgroud)\n最后一条指令给了我可以用来运行 nvm 的命令,但是当我运行它们时,出现错误
\n给出的命令
\nexport NVM_DIR="/home/gabriel/.nvm"\n[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh"\nRun Code Online (Sandbox Code Playgroud)\n输出
\n~/.nvm/nvm.sh (line 942): Unexpected \')\' found, expecting \'}\'\n "${NVM_NODE_PREFIX}")\n ^\nfrom sourcing file ~/.nvm/nvm.sh\n called on line 185 of file /usr/share/fish/config.fish\nin function \'.\' with arguments \'/home/gabriel/.nvm/nvm.sh\'\nsource: Error while reading file \xe2\x80\x9c/home/gabriel/.nvm/nvm.sh\xe2\x80\x9d\n\nRun Code Online (Sandbox Code Playgroud)\n
小智 10
所以,我找到了两种方法,
一种是仅使用nvm和 bash。每当您需要使用nvm命令时,请使用bash。然后返回fish并执行所有与节点相关的操作,在bash中更改nvm use [version]。然后在fish中工作,它仍然会使用NVM集的版本。
另一个是,安装curl,安装fisher,安装bass插件以支持fish中的bash风格,
sudo apt install curl
curl -sL https://git.io/fisher | source && fisher install jorgebucaran/fisher
fisher install edc/bass
创建nvm.fish
sudo nano ~/.config/fish/functions/nvm.fish
将此代码添加到文件 nvm.fish
function nvm
bass source ~/.nvm/nvm.sh --no-use ';' nvm $argv
end
Run Code Online (Sandbox Code Playgroud)
现在,您可以在 Fish 中使用nvm命令