mac使用mvn下载node-sass 会Binary download failed, trying source

m1 上使用nvm

以下node的版本可以直接下载(Binary download,而不是 trying source)而不用切换mac cpu架构

js 复制代码
 zhiwenwen@zhiwenwendeMBP cockpit % nvm install 14.15.5
Downloading and installing node v14.15.5...
Downloading https://nodejs.org/dist/v14.15.5/node-v14.15.5-darwin-x64.tar.xz...
################################################################################################################################### 100.0%
Computing checksum with shasum -a 256
Checksums matched!
Now using node v14.15.5 (npm v6.14.11)

经测试上述使用nvm直接下载的node Binary ,可以下载对应的node-sass版本不会报错,但是如果上述版本下载的source类似下面,那么再去下载对应的node-sass版本会报错

那么我们如何在node上使用nvm下载node不去下载source呢?

见下文

bash 复制代码
➜  sales_app git:(carDetail) nvm install 12.22.12
Downloading and installing node v12.22.12...
Downloading https://nodejs.org/dist/v12.22.12/node-v12.22.12-darwin-arm64.tar.xz...
-#O=-#      #        #                                                                                                                                                                                                        
curl: (22) The requested URL returned error: 404 
Binary download from https://nodejs.org/dist/v12.22.12/node-v12.22.12-darwin-arm64.tar.xz failed, trying source.
grep: /Users/gch/.nvm/.cache/bin/node-v12.22.12-darwin-arm64/node-v12.22.12-darwin-arm64.tar.xz: No such file or directory
Provided file to checksum does not exist.
Binary download failed, trying source.
Clang v3.5+ detected! CC or CXX not specified, will use Clang as C/C++ compiler!
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 --prefix=/Users/gch/.nvm/versions/node/v12.22.12 <
INFO: configure completed successfully
/Library/Developer/CommandLineTools/usr/bin/make -C out BUILDTYPE=Release V=0
  touch /Users/gch/.nvm/.cache/src/node-v12.22.12/files/out/Release/obj.target/node_dtrace_header.stamp
  touch /Users/gch/.nvm/.cache/src/node-v12.22.12/files/out/Release/obj.target/specialize_node_d.stamp
  touch /Users/gch/.nvm/.cache/src/node-v12.22.12/files/out/Release/obj.target/tools/v8_gypfiles/v8_headers.stamp
  c++ -o /Users/gch/.nvm/.cache/src/node-v12.22.12/files/out/Release/obj.target/icui18n/deps/icu-small/source/i18n/nultrans.o ../deps/icu-small/source/i18n/nultrans.cpp '-DV8_DEPRECATION_WARNINGS' '-DV8_IMMINENT_DEPRECATION_WARNINGS' '-D_DARWIN_USE_64_BIT_INODE=1' '-DOPENSSL_NO_PINSHARED' '-DOPENSSL_THREADS' '-DOPENSSL_NO_ASM' '-DU_I18N_IMPLEMENTATION=1' '-DU_ATTRIBUTE_DEPRECATED=' '-D_CRT_SECURE_NO_DEPRECATE=' '-DU_STATIC_IMPLEMENTATION=1' '-DUCONFIG_NO_SERVICE=1' '-DU_ENABLE_DYLOAD=0' '-DU_HAVE_STD_STRING=1' '-DUCONFIG_NO_BREAK_ITERATION=0' -I../deps/icu-small/source/i18n -I../deps/icu-small/source/common  -O3 -gdwarf-2 -mmacosx-version-min=10.10 -arch arm64 -Wall -Wendif-labels -W -Wno-unused-parameter -std=gnu++1y -stdlib=libc++ -fno-exceptions -fno-strict-aliasing -MMD -MF /Users/gch/.nvm/.cache/src/node-v12.22.12/files/out/Release/.deps//Users/gch/.nvm/.cache/src/node-v12.22.12/files/out/Release/obj.target/icui18n/deps/icu-small/source/i18n/nultrans.o.d.raw   -c
  c++ -o /Users/gch/.nvm/.cache/src/node-v12.22.12/files/out/Release/obj.target/icui18n/deps/icu-small/source/i18n/uspoof_conf.o ../deps/icu-small/source/i18n/uspoof_conf.cpp '-DV8_DEPRECATION_WARNINGS' '-DV8_IMMINENT_DEPRECATION_WARNINGS' '-D_DARWIN_USE_64_BIT_INODE=1' '-DOPENSSL_NO_PINSHARED' '-DOPENSSL_THREADS' '-DOPENSSL_NO_ASM' '-DU_I18N_IMPLEMENTATION=1' '-DU_ATTRIBUTE_DEPRECATED=' '-D_CRT_SECURE_NO_DEPRECATE=' '-DU_STATIC_IMPLEMENTATION=1' '-DUCONFIG_NO_SERVICE=1' '-DU_ENABLE_DYLOAD=0' '-DU_HAVE_STD_STRING=1' '-DUCONFIG_NO_BREAK_ITERATION=0' -I../deps/icu-small/source/i18n -I../deps/icu-small/source/common  -O3 -gdwarf-2 -mmacosx-version-min=10.10 -arch arm64 -Wall -Wendif-labels -W -Wno-unused-parameter -std=gnu++1y -stdlib=libc++ -fno-exceptions -fno-strict-aliasing -MMD -MF /Users/gch/.nvm/.cache/src/node-v12.22.12/files/out/Release/.deps//Users/gch/.nvm/.cache/src/node-v12.22.12/files/out/Release/obj.target/icui18n/deps/icu-small/source/i18n/uspoof_conf.o.d.raw   -c

经过分析发现命令安装node版本时,M1电脑自动拼接路径如下:

bash 复制代码
https://nodejs.org/dist/v12.22.12/node-v12.22.12-darwin-arm64.tar.xz

arm64是M1特有的软件命令方式 目前node官网不提供此类的压缩包压缩包官网

解决方案

执行install命令前先执行M1兼容命令:
arch -x86_64 zsh

然后再执行install会自动修复下载版本的链接:

bash 复制代码
➜  ~ arch -x86_64 zsh
➜  ~ nvm install 12.22.0         
Downloading and installing node v12.22.0...
Downloading https://nodejs.org/dist/v12.22.0/node-v12.22.0-darwin-x64.tar.xz...
###################################################################################################### 100.0%
Computing checksum with shasum -a 256
Checksums matched!
Now using node v12.22.0 (npm v6.14.11)

注:使用 arch -arm64 zsh 切换为arm架构;显示当前主机硬件架构类型 使用arch命令;查看当前arch版本命令使用 arch --version

相关推荐
a cool fish(无名)1 小时前
9.1无法恢复的错误与 panic!
rust
ghostwritten4 小时前
macOS安装配置Unbound DNS完整指南
macos·策略模式·dns
超龄超能程序猿5 小时前
Vue3 + Electron 技术栈下 MAC 地址获取的方法、准确性优化与应对策略
macos·electron·策略模式
ihui数学建模17 小时前
【Mac版】Linux 入门命令行快捷键+联想记忆
linux·运维·macos
勇敢牛牛_19 小时前
【OneAPI】网页搜索API和网页正文提取API
rust·oneapi
受之以蒙20 小时前
Rust & WebAssembly:探索js-sys的奇妙世界
笔记·rust·webassembly
dzj20211 天前
VS Code中配置使用slint(Rust)的一个小例子
ui·rust·slint
大卫小东(Sheldon)1 天前
智能生成git提交消息工具 GIM 发布 1.7 版本了
git·ai·rust
寻月隐君1 天前
Rust 泛型 Trait:关联类型与泛型参数的核心区别
后端·rust·github
苏鑫的博客1 天前
Rust 代理抓包工具 Lynx Proxy 开源之路
rust