You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

无.tool-versions文件时如何全局使用Homebrew安装的Node.js?

解决asdf全局默认使用Homebrew安装的Node.js问题

你已经通过Homebrew安装了Node.js:

brew install node

同时也安装了带Node.js插件的asdf,希望仅在部分项目中使用asdf,全局环境下默认用Homebrew的Node.js,当前无.tool-versions文件时会报错:

No version is set for command node
Consider adding one of the following versions in your config file at
nodejs 19.0.0
nodejs 19.0.1
nodejs 19.1.0
nodejs 19.2.0

可以实现这个需求,具体操作如下:

  • 执行以下命令,将asdf全局默认的Node.js版本设置为系统版本(即Homebrew安装的Node.js):

    asdf global nodejs system
    

    这个命令会在~/.tool-versions文件中添加一行nodejs system,当你在没有项目本地.tool-versions的目录下时,asdf就会自动使用系统(Homebrew)的Node.js。

  • 若后续需要在特定项目中使用asdf管理的Node.js版本,只需在项目根目录创建.tool-versions文件,写入指定版本即可,比如:

    echo "nodejs 19.2.0" > .tool-versions
    

    进入该项目目录时,asdf会自动切换到指定版本。

这样就能满足「全局用Homebrew Node.js,仅指定项目用asdf管理版本」的需求。

内容的提问来源于stack exchange,提问作者Azat S.

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.09 17:45:32