nvm:无法安装v8.6.0,需要安装旧版nodejs 无法安装,(macos bigsur)

时间:2021-06-24 16:30:58

标签: node.js macos nvm

我需要安装旧版本的 node 才能运行产品,但无法使用 nvm install 8.6.0 命令安装 8.6.0 版本。

收到两个不同的警告,

  1. 警告:C++ 编译器太旧,需要 g++ 4.9.4 或 clang++ 3.4.2 (CXX=c++)

  2. 警告:在配置阶段发出警告 xcode-select: 错误:工具 'xcodebuild' 需要 Xcode,但活动开发者目录 '/Library/Developer/CommandLineTools' 是命令行工具实例

Downloading and installing node v8.6.0...
Downloading https://nodejs.org/dist/v8.6.0/node-v8.6.0-darwin-arm64.tar.xz...
##O=- #     #                                                                                                                                                                                              
curl: (22) The requested URL returned error: 404 
Binary download from https://nodejs.org/dist/v8.6.0/node-v8.6.0-darwin-arm64.tar.xz failed, trying source.
grep: /Users/aravind/.nvm/.cache/bin/node-v8.6.0-darwin-arm64/node-v8.6.0-darwin-arm64.tar.xz: No such file or directory
Provided file to checksum does not exist.
Binary download failed, trying source.
Detected that you have 8 CPU core(s)
Running with 7 threads to speed up the build
Clang v3.5+ detected! CC or CXX not specified, will use Clang as C/C++ compiler!
Local cache found: ${NVM_DIR}/.cache/src/node-v8.6.0/node-v8.6.0.tar.xz
Checksums match! Using existing downloaded archive ${NVM_DIR}/.cache/src/node-v8.6.0/node-v8.6.0.tar.xz
$>./configure --prefix=/Users/aravind/.nvm/versions/node/v8.6.0 <
WARNING: C++ compiler too old, need g++ 4.9.4 or clang++ 3.4.2 (CXX=c++)
creating ./icu_config.gypi
* Using ICU in deps/icu-small
creating ./icu_config.gypi
{ 'target_defaults': { 'cflags': [],
                       'default_configuration': 'Release',
                       'defines': [],
                       'include_dirs': [],
                       'libraries': []},
  'variables': { 'asan': 0,
                 'coverage': 'false',
                 'debug_devtools': 'node',
                 'debug_http2': 'false',
                 'debug_nghttp2': 'false',
                 'force_dynamic_crt': 0,
                 'host_arch': 'arm64',
                 'icu_data_file': 'icudt59l.dat',
                 'icu_data_in': '../../deps/icu-small/source/data/in/icudt59l.dat',
                 'icu_endianness': 'l',
                 'icu_gyp_path': 'tools/icu/icu-generic.gyp',
                 'icu_locales': 'en,root',
                 'icu_path': 'deps/icu-small',
                 'icu_small': 'true',
                 'icu_ver_major': '59',
                 'llvm_version': 0,
                 'node_byteorder': 'little',
                 'node_enable_d8': 'false',
                 'node_enable_v8_vtunejit': 'false',
                 'node_install_npm': 'true',
                 'node_module_version': 57,
                 'node_no_browser_globals': 'false',
                 'node_prefix': '/Users/aravind/.nvm/versions/node/v8.6.0',
                 'node_release_urlbase': '',
                 'node_shared': 'false',
                 'node_shared_cares': 'false',
                 'node_shared_http_parser': 'false',
                 'node_shared_libuv': 'false',
                 'node_shared_openssl': 'false',
                 'node_shared_zlib': 'false',
                 'node_tag': '',
                 'node_use_bundled_v8': 'true',
                 'node_use_dtrace': 'true',
                 'node_use_etw': 'false',
                 'node_use_lttng': 'false',
                 'node_use_openssl': 'true',
                 'node_use_perfctr': 'false',
                 'node_use_v8_platform': 'true',
                 'node_without_node_options': 'false',
                 'openssl_fips': '',
                 'openssl_no_asm': 0,
                 'shlib_suffix': '57.dylib',
                 'target_arch': 'arm64',
                 'uv_parent_path': '/deps/uv/',
                 'uv_use_dtrace': 'true',
                 'v8_enable_gdbjit': 0,
                 'v8_enable_i18n_support': 1,
                 'v8_enable_inspector': 1,
                 'v8_no_strict_aliasing': 1,
                 'v8_optimized_debug': 0,
                 'v8_promise_internal_field_count': 1,
                 'v8_random_seed': 0,
                 'v8_trace_maps': 0,
                 'v8_use_snapshot': 'true',
                 'want_separate_host_toolset': 0,
                 'xcode_version': 0}}
creating ./config.gypi
creating ./config.mk
WARNING: warnings were emitted in the configure phase
xcode-select: error: tool 'xcodebuild' requires Xcode, but active developer directory '/Library/Developer/CommandLineTools' is a command line tools instance

Traceback (most recent call last):
  File "./configure", line 1452, in <module>
    run_gyp(gyp_args)
  File "./tools/gyp_node.py", line 53, in run_gyp
    rc = gyp.main(args)
  File "./tools/gyp/pylib/gyp/__init__.py", line 538, in main
    return gyp_main(args)
  File "./tools/gyp/pylib/gyp/__init__.py", line 523, in gyp_main
    generator.GenerateOutput(flat_list, targets, data, params)
  File "./tools/gyp/pylib/gyp/generator/make.py", line 2179, in GenerateOutput
    part_of_all=qualified_target in needed_targets)
  File "./tools/gyp/pylib/gyp/generator/make.py", line 800, in Write
    self.Pchify))
  File "./tools/gyp/pylib/gyp/generator/make.py", line 1195, in WriteSources
    cflags = self.xcode_settings.GetCflags(configname)
  File "./tools/gyp/pylib/gyp/xcode_emulation.py", line 628, in GetCflags
    archs = self.GetActiveArchs(self.configname)
  File "./tools/gyp/pylib/gyp/xcode_emulation.py", line 486, in GetActiveArchs
    xcode_archs_default = GetXcodeArchsDefault()
  File "./tools/gyp/pylib/gyp/xcode_emulation.py", line 118, in GetXcodeArchsDefault
    xcode_version, _ = XcodeVersion()
  File "./tools/gyp/pylib/gyp/xcode_emulation.py", line 1406, in XcodeVersion
    version = re.match(r'(\d\.\d\.?\d*)', version).groups()[0]
AttributeError: 'NoneType' object has no attribute 'groups'
nvm: install v8.6.0 failed! 

1 个答案:

答案 0 :(得分:0)

我通过创建一个新终端作为 rosetta 终端解决了这个问题

您可以使用以下步骤创建 rosetta 终端

Applications -> Utilities -> right click on terminal and duplicate -> right click on duplicate terminal -> Get info -> 选择 open using Rosetta 并将终端重命名为 {{ 1}}

通过rosetta-terminal安装NVM, 现在安装所需的节点版本。