【问题标题】:Globally installed npm package not found when installed with NVM using oh-my-zsh使用 oh-my-zsh 与 NVM 一起安装时找不到全局安装的 npm 包
【发布时间】:2022-01-17 04:08:42
【问题描述】:

使用 oh-my-zsh(在 Mac 上),我安装了 NVM 并且正在运行最新的 LTS 版本的 Node。

我已经全局安装了这个包的两个版本:https://github.com/IBM/openapi-to-graphql

which openapi-to-graphql 返回/Users/myUser/.nvm/versions/node/v16.13.0/bin/openapi-to-graphql,这是我所期望的。

然而,

which openapi-to-graphql-cli 返回openapi-to-graphql-cli not found 即使我可以看到它,如果我run npm list --g --depth 0

/Users/myUser/.nvm/versions/node/v16.13.0/lib
├── corepack@0.10.0
├── lerna@4.0.0
├── npm@8.1.0
├── openapi-to-graphql-cli@2.5.2
├── openapi-to-graphql@2.5.2
└── read-package-json@4.1.1

如果我对其他包运行which 命令,除了read-package-json 也会返回错误之外,它们中的大多数都会按预期返回。

我已尝试在全球范围内卸载/重新安装 openapi-to-graphql-cli 软件包,但没有成功。

我需要在终端运行的命令是openapi-to-graphql-cli <inputFile> --save <outputFile>

【问题讨论】:

    标签: node.js npm node-modules nvm oh-my-zsh


    【解决方案1】:

    解决方案有两个。首先,在发布时包中存在一个错误,导致 CLI 无法工作:https://github.com/IBM/openapi-to-graphql/issues/418

    我回滚到版本 2.5.0 已修复此问题。

    第二个问题是由于错误,我假设我在终端中运行了错误的命令,所以我开始运行openapi-to-graphql-cli <command>,这是不正确的。根据the docs,命令应以openapi-to-graphql 开头。

    【讨论】:

      猜你喜欢
      • 2015-12-23
      • 2020-12-09
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-11-17
      • 2018-05-25
      • 1970-01-01
      相关资源
      最近更新 更多