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

nvm安装Node.js v12提示python not found导致安装失败

问题现象

通过nvm安装Node.js 12版本时,系统已安装Python,但安装流程的源码编译阶段提示python not found报错,安装失败。

当前环境版本信息

~ % nvm --version
0.33.0

~ % python --version
Python 3.10.5

安装报错输出

执行nvm install 12时返回以下错误:

~ % nvm install 12
Downloading and installing node v12.22.12...
Local cache found: $NVM_DIR/.cache/bin/node-v12.22.12-darwin-arm64/node-v12.22.12-darwin-arm64.tar.xz
Computing checksum with shasum -a 256
Provided checksum to compare to is empty.
Checksum check failed!
Removing the broken local cache...
Downloading https://nodejs.org/dist/v12.22.12/node-v12.22.12-darwin-arm64.tar.xz...

Computing checksum with shasum -a 256
Provided checksum to compare to is empty.
tar: Error opening archive: Unrecognized archive format
Binary download failed, trying source.
Local cache found: $NVM_DIR/.cache/src/node-v12.22.12/node-v12.22.12.tar.xz
Checksums match! Using existing downloaded archive $NVM_DIR/.cache/src/node-v12.22.12/node-v12.22.12.tar.xz
./configure: line 3: exec: python: not found
nvm: install v12.22.12 failed!

调试信息

执行nvm debug输出如下:

~ % nvm debug
nvm --version: v0.33.0
$SHELL: /bin/zsh
$HOME: /Users/onur.ozkir
$NVM_DIR: '$HOME/.nvm'
$PREFIX: ''
$NPM_CONFIG_PREFIX: ''
nvm current: none
which node: node not found
which iojs: iojs not found
which npm: /opt/homebrew/bin/npm
npm config get prefix: env: node: No such file or directory
npm root -g: env: node: No such file or directory
故障原因
  • 当前使用的nvm 0.33.0版本过旧,版本发布时Apple Silicon(darwin-arm64)架构尚未推出,版本内置的校验和列表里没有对应架构的Node.js 12安装包校验值,导致二进制包下载校验失败,自动回退到源码编译流程。
  • Node.js 12本身没有提供官方darwin-arm64架构的预编译二进制包,即使升级nvm也会触发源码编译。
  • Node.js 12的构建脚本硬编码调用python命令,而当前系统仅默认提供python3命令,没有配置python命令的别名或软链接,导致编译时找不到Python。
解决步骤

按顺序执行以下操作即可完成安装:

  1. 升级nvm到最新版本,修复老版本的架构适配、校验和缺失问题
cd ~/.nvm && git pull origin master

执行完成后关闭当前终端,重新打开终端,执行nvm --version确认版本号为0.39.0及以上。

  1. 配置python命令别名,让构建脚本可以找到Python
echo "alias python=python3" >> ~/.zshrc
source ~/.zshrc

执行完成后输入python --version,确认能正常返回Python 3.10.5的版本信息即可。

  1. 清除之前损坏的nvm缓存,重新执行安装
rm -rf $NVM_DIR/.cache
nvm install 12

如果源码编译过程中出现其他架构兼容类报错,可通过Rosetta 2转译安装x86版本的Node.js 12:

  1. 安装Rosetta 2组件
softwareupdate --install-rosetta
  1. 以x86模式启动shell后重新执行安装
arch -x86_64 zsh
nvm install 12
exit

安装完成后退出x86模式的shell,回到原生arm64终端即可正常使用Node.js 12。


内容的提问来源于stack exchange,提问作者Onur Özkır

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.08.29 12:09:18