gpt4 book ai didi

node.js - fish shell nvm 告诉我 node 和 npm 是 "currently not installed"但它们是

转载 作者:行者123 更新时间:2023-12-04 11:44:09 28 4
gpt4 key购买 nike

在最近更新了 OS X Big Sur 上的 fish、fisher、bass 和 nvm 之后,我在使用 fish shell 时遇到了 npm 和 node 问题。
$ node -v

type: Invalid combination of options
Fish nvm: 'node' is currently not installed, try running npm i -g node
$ npm -v
type: Invalid combination of options
Fish nvm: 'npm' is currently not installed, try running npm i -g npm
NVM 似乎工作正常:
$ nvm列表
->     v10.16.0
v12.4.0
v12.16.1
v13.11.0
v14.16.0
system
default -> 10.16.0 (-> v10.16.0)
iojs -> N/A (default)
unstable -> N/A (default)
node -> stable (-> v14.16.0) (default)
stable -> 14.16 (-> v14.16.0) (default)
lts/* -> lts/fermium (-> v14.16.0)
lts/argon -> v4.9.1 (-> N/A)
lts/boron -> v6.17.1 (-> N/A)
lts/carbon -> v8.17.0 (-> N/A)
lts/dubnium -> v10.24.0 (-> N/A)
lts/erbium -> v12.21.0 (-> N/A)
lts/fermium -> v14.16.0
它成功地切换了 Node 版本。
$ nvm 使用 v14 Now using node v14.16.0 (npm v6.14.11) $哪个 Node /Users/brianfogel/.nvm/versions/node/v14.16.0/bin/node $ which npm /Users/brianfogel/.nvm/versions/node/v14.16.0/bin/npm对于其他上下文,这里有一些其他可能有助于展示的内容:
$ fish --版本 fish, version 3.2.0 $ Fisher --version fisher, version 4.2.0 $ nvm -v 0.37.2 $ cat ~/.config/fish/functions/node.fish
function node -d "Server-side JavaScript runtime" -w node
__nvm_run "node" $argv
end
$ cat ~/.config/fish/functions/npm.fish
function npm -d "node package manager" -w npm
__nvm_run "npm" $argv
end
$ cat ~/.config/fish/functions/nvm.fish
function nvm
if not type -q bass
echo 'Bass is not installed please install it running fisher edc/bass'
return
end
set -q NVM_DIR; or set -gx NVM_DIR ~/.nvm
set -q nvm_prefix; or set -gx nvm_prefix $NVM_DIR

bass source $nvm_prefix/nvm.sh --no-use ';' nvm $argv

set bstatus $status

if test $bstatus -gt 0
return $bstatus
end

if test (count $argv) -lt 1
return 0
end

if test $argv[1] = "use"; or test $argv[1] = "install"
set -g NVM_HAS_RUN 1
end
end
$ cat/usr/local/bin/node
#! /usr/bin/env fish
__nvm_run "node" $argv
$ cat/usr/local/bin/npm
#!/usr/bin/env fish
__nvm_run "npm" $argv
$ $ set --show fish_user_paths
$fish_user_paths: set in global scope, unexported, with 10 elements
$fish_user_paths[1]: |/Users/brianfogel/.pub-cache/bin|
$fish_user_paths[2]: |/Users/brianfogel/flutter/flutter/.pub-cache/bin|
$fish_user_paths[3]: |/Users/brianfogel/flutter/flutter/bin|
$fish_user_paths[4]: |/usr/local/sbin|
$fish_user_paths[5]: |/Applications/Postgres.app/Contents/Versions/latest/bin|
$fish_user_paths[6]: |/Users/brianfogel/.npm-global/bin|
$fish_user_paths[7]: |/usr/local/Cellar/php/7.3.4_1/bin|
$fish_user_paths[8]: |/usr/local/sbin|
$fish_user_paths[9]: |/Applications/Postgres.app/Contents/Versions/latest/bin|
$fish_user_paths[10]: |/Users/brianfogel/.yarn/bin|
$fish_user_paths: set in universal scope, unexported, with 4 elements
$fish_user_paths[1]: |/Users/brianfogel/.npm-global/bin|
$fish_user_paths[2]: |/usr/local/sbin|
$fish_user_paths[3]: |/Applications/Postgres.app/Contents/Versions/latest/bin|
$fish_user_paths[4]: |/Users/brianfogel/.yarn/bin|

最佳答案

https://github.com/FabioAntunes/fish-nvm已经更新。安装或更新插件可解决此问题。

关于node.js - fish shell nvm 告诉我 node 和 npm 是 "currently not installed"但它们是,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/66464067/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com