I'm not good at English, please read with consideration
You can also install node v22.2.0
brew install llvm@12
/usr/local/Homebrew/Library/Homebrew/shims/super/cc # on line 80
"#{ENV["HOMEBREW_PREFIX"]}/opt/llvm/bin/#{Regexp.last_match(1)}"
rewrite this as below
"#{ENV["HOMEBREW_PREFIX"]}/opt/llvm@12/bin/#{Regexp.last_match(1)}"
llvm@15 is required, there are several ways
How to install llvm@13 with Homerew on macOS High Sierra 10.13.6? Got "Built target lldELF" error
or
brew install --cc=llvm_clang llvm@15
download, Extraction, copying, takes time, before make
/tmp/llvmA15...../llvm-project-15.0.7.src/lldb/source/Host/macosx/objcxx/HostInfoMacOSX.mm # on line 236
if (cputype == CPU_TYPE_ARM64 && cpusubtype == CPU_SUBTYPE_ARM64E) {
rewrite this as below
if (cputype == CPU_TYPE_ARM64) {
After installing llvm@15
/usr/local/Homebrew/Library/Homebrew/shims/super/cc # on line 80
"#{ENV["HOMEBREW_PREFIX"]}/opt/llvm@12/bin/#{Regexp.last_match(1)}"
rewrite this as below
"#{ENV["HOMEBREW_PREFIX"]}/opt/llvm@15/bin/#{Regexp.last_match(1)}"
Set environment variables in .zshrc or .bashrc
export HOMEBREW_NO_INSTALL_FROM_API=1
brew edit node
rewrite line 36 as a comment
# on_macos do
# depends_on "llvm" => [:build, :test] if DevelopmentTools.clang_build_version <= 1100
# end
Disable System Integrity Protection (SIP)
https://developer.apple.com/documentation/security/disabling_and_enabling_system_integrity_protection
Rewrite header for c-ares installation,which depends on it
sudo vim /usr/include/dispatch/dispatch.h # line 38
#if !defined(HAVE_UNISTD_H) || HAVE_UNISTD_H
rewrite this as below
#if !defined(HAVE_UNISTD_H) // || HAVE_UNISTD_H
Copy and rewrite header for node installation
sudo cp /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/os/signpost.h /usr/include/os/
sudo vim /usr/include/os/signpost.h # on line 280
#define os_signpost_event_emit(log, event_id, name, ...) \\
os_signpost_emit_with_type(log, OS_SIGNPOST_EVENT, \\
event_id, name, ##__VA_ARGS__)
rewrite this as below
#define os_signpost_event_emit(log, event_id, name, ...)
// os_signpost_emit_with_type(log, OS_SIGNPOST_EVENT, \\
event_id, name, ##__VA_ARGS__)
brew install --cc=llvm_clang node
Enable SIP if you don't want to touch the system
Summarized, read the link for more details
https://github.com/orgs/Homebrew/discussions/4751