我已经在本地安装了npm软件包而没有错误,并且运行npm list --depth=0
确认已安装。但是,在终端中从该pkg运行任何命令都会返回zsh: command not found: <command name>
基于此SO线程,我已经在〜/ .zshrc的开头添加了source /Users/YOURSERNAME/.bash_profile
,但无济于事。有时它还会显示no such file or directory:/Users/YOURSERNAME/.bash_profile
我可以做的其他任何检查吗?
答案 0 :(得分:0)
将其放在您的.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