代码之家  ›  专栏  ›  技术社区  ›  santoku

已安装的npm包的“zsh:未找到命令”

  •  0
  • santoku  · 技术社区  · 4 年前

    我已经在本地安装了一个npm包,没有错误,并且正在运行 npm list --depth=0 确认已安装。但是,在终端中从该pkg运行任何命令都会返回 zsh: command not found: <command name>

    基于此SO线程,我已经添加了 source /Users/YOURSERNAME/.bash_profile 在~/的开头。zshrc,但无济于事。有时它也会显示 no such file or directory:/Users/YOURSERNAME/.bash_profile 我还能做其他检查吗?

    0 回复  |  直到 4 年前
        1
  •  0
  •   ofthelit    4 年前

    把这个放进你的 .zshrc 改为文件:

    NPM_PACKAGES="${HOME}/.npm-packages"
    export PATH="$PATH:$NPM_PACKAGES/bin"
    # Preserve MANPATH if you already defined it somewhere in your config.
    # Otherwise, fall back to `manpath` so we can inherit from `/etc/manpath`.
    export MANPATH="${MANPATH-$(manpath)}:$NPM_PACKAGES/share/man"
    

    从…起 https://dev.to/rrampage/5-npm-and-node-tips-to-make-your-machine-safer-3g0l

    之后重新加载zsh设置:

    source ~/.zshrc