在 Apple M1 (Big Sur) 上使用 node-gyp 安装本机 Node.js 插件时出错

Axe*_*ier 7 xcode node.js node-gyp macos-big-sur apple-m1

我正在用来yarn安装包括asset-hash在内的软件包,它依赖于Metrohash

\n

我运行时经常出现以下错误:

\n
yarn install v1.22.10\n[1/4]   Resolving packages...\n[2/4]   Fetching packages...\n[3/4]   Linking dependencies...\n[4/4]   Building fresh packages...\n[-/11] \xe2\xa0\xa0 waiting...\n[10/11] \xe2\xa0\xa0 metrohash\nerror /Users/johndoe/Projects/my-project/node_modules/metrohash: Command failed.\nExit code: 1\nCommand: node-gyp rebuild\nArguments:\nDirectory: /Users/johndoe/Projects/my-project/node_modules/metrohash\nOutput:\ngyp info it worked if it ends with ok\ngyp info using node-gyp@3.8.0\ngyp info using node@15.10.0 | darwin | arm64\ngyp info spawn /usr/bin/python2\ngyp info spawn args [\ngyp info spawn args   \'/Users/johndoe/Projects/my-project/node_modules/node-gyp/gyp/gyp_main.py\',\ngyp info spawn args   \'binding.gyp\',\ngyp info spawn args   \'-f\',\ngyp info spawn args   \'make\',\ngyp info spawn args   \'-I\',\ngyp info spawn args   \'/Users/johndoe/Projects/my-project/node_modules/metrohash/build/config.gypi\',\ngyp info spawn args   \'-I\',\ngyp info spawn args   \'/Users/johndoe/Projects/my-project/node_modules/node-gyp/addon.gypi\',\ngyp info spawn args   \'-I\',\ngyp info spawn args   \'/Users/johndoe/.node-gyp/15.10.0/include/node/common.gypi\',\ngyp info spawn args   \'-Dlibrary=shared_library\',\ngyp info spawn args   \'-Dvisibility=default\',\ngyp info spawn args   \'-Dnode_root_dir=/Users/johndoe/.node-gyp/15.10.0\',\ngyp info spawn args   \'-Dnode_gyp_dir=/Users/johndoe/Projects/my-project/node_modules/node-gyp\',\ngyp info spawn args   \'-Dnode_lib_file=/Users/johndoe/.node-gyp/15.10.0/<(target_arch)/node.lib\',\ngyp info spawn args   \'-Dmodule_root_dir=/Users/johndoe/Projects/my-project/node_modules/metrohash\',\ngyp info spawn args   \'-Dnode_engine=v8\',\ngyp info spawn args   \'--depth=.\',\ngyp info spawn args   \'--no-parallel\',\ngyp info spawn args   \'--generator-output\',\ngyp info spawn args   \'build\',\ngyp info spawn args   \'-Goutput_dir=.\'\ngyp info spawn args ]\ngyp info spawn make\ngyp info spawn args [ \'BUILDTYPE=Release\', \'-C\', \'build\' ]\nclang: warning: argument unused during compilation: \'-msse4.2\' [-Wunused-command-line-argument]\n  CXX(target) Release/obj.target/metrohash/src/metrohash_wrapper.o\n  CXX(target) Release/obj.target/metrohash/src/metrohash128.o\nclang: warning: argument unused during compilation: \'-msse4.2\' [-Wunused-command-line-argument]\n  CXX(target) Release/obj.target/metrohash/src/metrohash128crc.o\nclang: warning: argument unused during compilation: \'-msse4.2\' [-Wunused-command-line-argument]\nIn file included from ../src/metrohash128crc.cpp:27:\nIn file included from /Library/Developer/CommandLineTools/usr/lib/clang/12.0.0/include/nmmintrin.h:15:\nIn file included from /Library/Developer/CommandLineTools/usr/lib/clang/12.0.0/include/smmintrin.h:13:\nIn file included from /Library/Developer/CommandLineTools/usr/lib/clang/12.0.0/include/tmmintrin.h:13:\nIn file included from /Library/Developer/CommandLineTools/usr/lib/clang/12.0.0/include/pmmintrin.h:13:\nIn file included from /Library/Developer/CommandLineTools/usr/lib/clang/12.0.0/include/emmintrin.h:13:\nIn file included from /Library/Developer/CommandLineTools/usr/lib/clang/12.0.0/include/xmmintrin.h:13:\n/Library/Developer/CommandLineTools/usr/lib/clang/12.0.0/include/mmintrin.h:33:5: error: use of undeclared identifier \'__builtin_ia32_emms\'; did you mean \'__builtin_isless\'?\n    __builtin_ia32_emms();\n    ^\n/Library/Developer/CommandLineTools/usr/lib/clang/12.0.0/include/mmintrin.h:33:5: note: \'__builtin_isless\' declared here\n/Library/Developer/CommandLineTools/usr/lib/clang/12.0.0/include/mmintrin.h:33:25: error: too few arguments to function call, expected 2, have 0\n    __builtin_ia32_emms();\n                        ^\n/Library/Developer/CommandLineTools/usr/lib/clang/12.0.0/include/mmintrin.h:50:19: error: use of undeclared identifier \'__builtin_ia32_vec_init_v2si\'\n    return (__m64)__builtin_ia32_vec_init_v2si(__i, 0);\n                  ^\n/Library/Developer/CommandLineTools/usr/lib/clang/12.0.0/include/mmintrin.h:67:12: error: use of undeclared identifier \'__builtin_ia32_vec_ext_v2si\'\n    return __builtin_ia32_vec_ext_v2si((__v2si)__m, 0);\n           ^\n/Library/Developer/CommandLineTools/usr/lib/clang/12.0.0/include/mmintrin.h:129:19: error: use of undeclared identifier \'__builtin_ia32_packsswb\'\n    return (__m64)__builtin_ia32_packsswb((__v4hi)__m1, (__v4hi)__m2);\n                  ^\n/Library/Developer/CommandLineTools/usr/lib/clang/12.0.0/include/mmintrin.h:159:19: error: use of undeclared identifier \'__builtin_ia32_packssdw\'\n    return (__m64)__builtin_ia32_packssdw((__v2si)__m1, (__v2si)__m2);\n                  ^\n/Library/Developer/CommandLineTools/usr/lib/clang/12.0.0/include/mmintrin.h:189:19: error: use of undeclared identifier \'__builtin_ia32_packuswb\'\n    return (__m64)__builtin_ia32_packuswb((__v4hi)__m1, (__v4hi)__m2);\n                  ^\n/Library/Developer/CommandLineTools/usr/lib/clang/12.0.0/include/mmintrin.h:216:19: error: use of undeclared identifier \'__builtin_ia32_punpckhbw\'\n    return (__m64)__builtin_ia32_punpckhbw((__v8qi)__m1, (__v8qi)__m2);\n                  ^\n/Library/Developer/CommandLineTools/usr/lib/clang/12.0.0/include/mmintrin.h:239:19: error: use of undeclared identifier \'__builtin_ia32_punpckhwd\'\n    return (__m64)__builtin_ia32_punpckhwd((__v4hi)__m1, (__v4hi)__m2);\n                  ^\n/Library/Developer/CommandLineTools/usr/lib/clang/12.0.0/include/mmintrin.h:260:19: error: use of undeclared identifier \'__builtin_ia32_punpckhdq\'\n    return (__m64)__builtin_ia32_punpckhdq((__v2si)__m1, (__v2si)__m2);\n                  ^\n/Library/Developer/CommandLineTools/usr/lib/clang/12.0.0/include/mmintrin.h:287:19: error: use of undeclared identifier \'__builtin_ia32_punpcklbw\'\n    return (__m64)__builtin_ia32_punpcklbw((__v8qi)__m1, (__v8qi)__m2);\n                  ^\n/Library/Developer/CommandLineTools/usr/lib/clang/12.0.0/include/mmintrin.h:310:19: error: use of undeclared identifier \'__builtin_ia32_punpcklwd\'\n    return (__m64)__builtin_ia32_punpcklwd((__v4hi)__m1, (__v4hi)__m2);\n                  ^\n/Library/Developer/CommandLineTools/usr/lib/clang/12.0.0/include/mmintrin.h:331:19: error: use of undeclared identifier \'__builtin_ia32_punpckldq\'\n    return (__m64)__builtin_ia32_punpckldq((__v2si)__m1, (__v2si)__m2);\n                  ^\n/Library/Developer/CommandLineTools/usr/lib/clang/12.0.0/include/mmintrin.h:352:19: error: use of undeclared identifier \'__builtin_ia32_paddb\'; did you mean \'__builtin_arm_addg\'?\n    return (__m64)__builtin_ia32_paddb((__v8qi)__m1, (__v8qi)__m2);\n                  ^\n/Library/Developer/CommandLineTools/usr/lib/clang/12.0.0/include/mmintrin.h:352:19: note: \'__builtin_arm_addg\' declared here\n/Library/Developer/CommandLineTools/usr/lib/clang/12.0.0/include/mmintrin.h:352:19: error: first argument of MTE builtin function must be a pointer (\'__v8qi\' (vector of 8 \'char\' values) invalid)\n    return (__m64)__builtin_ia32_paddb((__v8qi)__m1, (__v8qi)__m2);\n                  ^                    ~~~~~~~~~~~~\n/Library/Developer/CommandLineTools/usr/lib/clang/12.0.0/include/mmintrin.h:373:19: error: use of undeclared identifier \'__builtin_ia32_paddw\'; did you mean \'__builtin_arm_addg\'?\n    return (__m64)__builtin_ia32_paddw((__v4hi)__m1, (__v4hi)__m2);\n                  ^\n/Library/Developer/CommandLineTools/usr/lib/clang/12.0.0/include/mmintrin.h:352:19: note: \'__builtin_arm_addg\' declared here\n    return (__m64)__builtin_ia32_paddb((__v8qi)__m1, (__v8qi)__m2);\n                  ^\n/Library/Developer/CommandLineTools/usr/lib/clang/12.0.0/include/mmintrin.h:373:19: error: first argument of MTE builtin function must be a pointer (\'__v4hi\' (vector of 4 \'short\' values) invalid)\n    return (__m64)__builtin_ia32_paddw((__v4hi)__m1, (__v4hi)__m2);\n                  ^                    ~~~~~~~~~~~~\n/Library/Developer/CommandLineTools/usr/lib/clang/12.0.0/include/mmintrin.h:394:19: error: use of undeclared identifier \'__builtin_ia32_paddd\'; did you mean \'__builtin_arm_addg\'?\n    return (__m64)__builtin_ia32_paddd((__v2si)__m1, (__v2si)__m2);\n                  ^\n/Library/Developer/CommandLineTools/usr/lib/clang/12.0.0/include/mmintrin.h:352:19: note: \'__builtin_arm_addg\' declared here\n    return (__m64)__builtin_ia32_paddb((__v8qi)__m1, (__v8qi)__m2);\n                  ^\n/Library/Developer/CommandLineTools/usr/lib/clang/12.0.0/include/mmintrin.h:394:19: error: first argument of MTE builtin function must be a pointer (\'__v2si\' (vector of 2 \'int\' values) invalid)\n    return (__m64)__builtin_ia32_paddd((__v2si)__m1, (__v2si)__m2);\n                  ^                    ~~~~~~~~~~~~\nfatal error: too many errors emitted, stopping now [-ferror-limit=]\n20 errors generated.\nmake: *** [Release/obj.target/metrohash/src/metrohash128crc.o] Error 1\ngyp ERR! build error\ngyp ERR! stack Error: `make` failed with exit code: 2\ngyp ERR! stack     at ChildProcess.onExit (/Users/johndoe/Projects/my-project/node_modules/node-gyp/lib/build.js:262:23)\ngyp ERR! stack     at ChildProcess.emit (node:events:378:20)\ngyp ERR! stack     at Process.ChildProcess._handle.onexit (node:internal/child_process:290:12)\ngyp ERR! System Darwin 20.3.0\ngyp ERR! command "/Users/johndoe/.nvm/versions/node/v15.10.0/bin/node" "/Users/johndoe/Projects/my-project/node_modules/metrohash/node_modules/.bin/node-gyp" "rebuild"\ngyp ERR! cwd /Users/johndoe/Projects/my-project/node_modules/metrohash\n
Run Code Online (Sandbox Code Playgroud)\n

我在用着

\n
    \n
  • MacBook Pro、苹果 M1
  • \n
  • macOS 大苏尔,11.2.2
  • \n
  • 节点 15.10.0
  • \n
  • 纱线 1.22.10
  • \n
\n

到目前为止我尝试过的

\n
    \n
  • 尝试了其他节点版本 12 和 14
  • \n
  • run xcode-select --install,删除该工具并重新安装
  • \n
  • brew update了并且brew upgrade
  • \n
  • 使用 Rosetta 执行终端
  • \n
\n

我认为该错误可能与 Apple M1 芯片或最新的 Big Sur 更新有关。

\n

任何帮助深表感谢。

\n

Cha*_*chi 5

请将node-sass版本与您的node版本进行比较

在此输入图像描述


Axe*_*ier 4

在同事的帮助下我可以修复这个错误。

我必须卸载brew并使用Rosetta重新安装它。然后我也使用 Rosetta 模式下的终端重新安装了节点和纱线。

  • 这只是模拟 x86_64 中所有内容的解决方法... (10认同)