sourcetree报错node:no such file or dierctory

166 阅读1分钟

image.png

我的node是通过nvm安装的,

路径类似于/Users/apple/.nvm/versions/node/v18.19.0/bin

根本原因:应该是sourcetree和系统环境的node的path不匹配导致;

解决办法:

1.将node放到你的环境变量中(具体方法自己搜索百度)

2.如果你的系统的node路径和sourcetree的node的路径(我认为这里的node路径就是项目中的node路径)是一致的,sourcetree还是报这个错误

我的解决办法就是,直接下载一个node环境,这样sourcetree就会直接去匹配node;

然后把项目和sourcetree都关闭,然后在重新打开,进行提交,就没有报错了

以下是我在解决这个问题中,用过的命令(Mac电脑)

echo $SHELL 

如果你看到 /bin/zsh,说明你正在使用 Zsh;如果是 /bin/bash,则说明你正在使用 Bash。

echo "source \$(brew --prefix nvm)/nvm.sh" >> .bash\_profile . \~/.bash\_profile

Zsh:

1.用文件编辑器打开

open -a "TextEdit" \~/.zshrc

open -a "TextEdit" . \~/.bash\_profile

2,进入zshrc,编写

export PATH="/Users/apple/.nvm/versions/node/v18.19.0/bin:\$PATH"

(这个是node的路径)

3.更新一下文件

source \~/.zshrc

4.看系统的path路径

echo \$PATH | tr ':' '\n'