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

标签 node.js npm fish nvm macos-big-sur

在最近更新了 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/

相关文章:

node.js - npm 错误!在 github 操作上构建脚本期间失败

node.js - 是否可以从下载的包中在本地运行 npm 包安装?

node.js - 确定 node_modules 是否需要重新安装的快速而肮脏的方法

fish shell 提示未正确显示符号

node.js - mongoose.connect() 中的 useNewURLParser 和 userCreateIndex 有什么作用?

javascript - Angular 2 Electron 项目编译出现问题

node.js - Volta 与yarn run 构建系统找不到指定的路径

node.js - Windows 上的 Nodejs 和 npm 安装

string - 如何在 fish shell 中的字符串中有换行符?

fish - 如何在 fish shell 中创建别名