繁体   English   中英

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

[英]Error installing native Node.js add-on with node-gyp on Apple M1 (Big Sur)

我正在使用yarn安装包,包括 assets -hash ,这取决于metrohash

我经常遇到以下错误:

yarn install v1.22.10
[1/4] 🔍  Resolving packages...
[2/4] 🚚  Fetching packages...
[3/4] 🔗  Linking dependencies...
[4/4] 🔨  Building fresh packages...
[-/11] ⠠ waiting...
[10/11] ⠠ metrohash
error /Users/johndoe/Projects/my-project/node_modules/metrohash: Command failed.
Exit code: 1
Command: node-gyp rebuild
Arguments:
Directory: /Users/johndoe/Projects/my-project/node_modules/metrohash
Output:
gyp info it worked if it ends with ok
gyp info using node-gyp@3.8.0
gyp info using node@15.10.0 | darwin | arm64
gyp info spawn /usr/bin/python2
gyp info spawn args [
gyp info spawn args   '/Users/johndoe/Projects/my-project/node_modules/node-gyp/gyp/gyp_main.py',
gyp info spawn args   'binding.gyp',
gyp info spawn args   '-f',
gyp info spawn args   'make',
gyp info spawn args   '-I',
gyp info spawn args   '/Users/johndoe/Projects/my-project/node_modules/metrohash/build/config.gypi',
gyp info spawn args   '-I',
gyp info spawn args   '/Users/johndoe/Projects/my-project/node_modules/node-gyp/addon.gypi',
gyp info spawn args   '-I',
gyp info spawn args   '/Users/johndoe/.node-gyp/15.10.0/include/node/common.gypi',
gyp info spawn args   '-Dlibrary=shared_library',
gyp info spawn args   '-Dvisibility=default',
gyp info spawn args   '-Dnode_root_dir=/Users/johndoe/.node-gyp/15.10.0',
gyp info spawn args   '-Dnode_gyp_dir=/Users/johndoe/Projects/my-project/node_modules/node-gyp',
gyp info spawn args   '-Dnode_lib_file=/Users/johndoe/.node-gyp/15.10.0/<(target_arch)/node.lib',
gyp info spawn args   '-Dmodule_root_dir=/Users/johndoe/Projects/my-project/node_modules/metrohash',
gyp info spawn args   '-Dnode_engine=v8',
gyp info spawn args   '--depth=.',
gyp info spawn args   '--no-parallel',
gyp info spawn args   '--generator-output',
gyp info spawn args   'build',
gyp info spawn args   '-Goutput_dir=.'
gyp info spawn args ]
gyp info spawn make
gyp info spawn args [ 'BUILDTYPE=Release', '-C', 'build' ]
clang: warning: argument unused during compilation: '-msse4.2' [-Wunused-command-line-argument]
  CXX(target) Release/obj.target/metrohash/src/metrohash_wrapper.o
  CXX(target) Release/obj.target/metrohash/src/metrohash128.o
clang: warning: argument unused during compilation: '-msse4.2' [-Wunused-command-line-argument]
  CXX(target) Release/obj.target/metrohash/src/metrohash128crc.o
clang: warning: argument unused during compilation: '-msse4.2' [-Wunused-command-line-argument]
In file included from ../src/metrohash128crc.cpp:27:
In file included from /Library/Developer/CommandLineTools/usr/lib/clang/12.0.0/include/nmmintrin.h:15:
In file included from /Library/Developer/CommandLineTools/usr/lib/clang/12.0.0/include/smmintrin.h:13:
In file included from /Library/Developer/CommandLineTools/usr/lib/clang/12.0.0/include/tmmintrin.h:13:
In file included from /Library/Developer/CommandLineTools/usr/lib/clang/12.0.0/include/pmmintrin.h:13:
In file included from /Library/Developer/CommandLineTools/usr/lib/clang/12.0.0/include/emmintrin.h:13:
In file included from /Library/Developer/CommandLineTools/usr/lib/clang/12.0.0/include/xmmintrin.h:13:
/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'?
    __builtin_ia32_emms();
    ^
/Library/Developer/CommandLineTools/usr/lib/clang/12.0.0/include/mmintrin.h:33:5: note: '__builtin_isless' declared here
/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
    __builtin_ia32_emms();
                        ^
/Library/Developer/CommandLineTools/usr/lib/clang/12.0.0/include/mmintrin.h:50:19: error: use of undeclared identifier '__builtin_ia32_vec_init_v2si'
    return (__m64)__builtin_ia32_vec_init_v2si(__i, 0);
                  ^
/Library/Developer/CommandLineTools/usr/lib/clang/12.0.0/include/mmintrin.h:67:12: error: use of undeclared identifier '__builtin_ia32_vec_ext_v2si'
    return __builtin_ia32_vec_ext_v2si((__v2si)__m, 0);
           ^
/Library/Developer/CommandLineTools/usr/lib/clang/12.0.0/include/mmintrin.h:129:19: error: use of undeclared identifier '__builtin_ia32_packsswb'
    return (__m64)__builtin_ia32_packsswb((__v4hi)__m1, (__v4hi)__m2);
                  ^
/Library/Developer/CommandLineTools/usr/lib/clang/12.0.0/include/mmintrin.h:159:19: error: use of undeclared identifier '__builtin_ia32_packssdw'
    return (__m64)__builtin_ia32_packssdw((__v2si)__m1, (__v2si)__m2);
                  ^
/Library/Developer/CommandLineTools/usr/lib/clang/12.0.0/include/mmintrin.h:189:19: error: use of undeclared identifier '__builtin_ia32_packuswb'
    return (__m64)__builtin_ia32_packuswb((__v4hi)__m1, (__v4hi)__m2);
                  ^
/Library/Developer/CommandLineTools/usr/lib/clang/12.0.0/include/mmintrin.h:216:19: error: use of undeclared identifier '__builtin_ia32_punpckhbw'
    return (__m64)__builtin_ia32_punpckhbw((__v8qi)__m1, (__v8qi)__m2);
                  ^
/Library/Developer/CommandLineTools/usr/lib/clang/12.0.0/include/mmintrin.h:239:19: error: use of undeclared identifier '__builtin_ia32_punpckhwd'
    return (__m64)__builtin_ia32_punpckhwd((__v4hi)__m1, (__v4hi)__m2);
                  ^
/Library/Developer/CommandLineTools/usr/lib/clang/12.0.0/include/mmintrin.h:260:19: error: use of undeclared identifier '__builtin_ia32_punpckhdq'
    return (__m64)__builtin_ia32_punpckhdq((__v2si)__m1, (__v2si)__m2);
                  ^
/Library/Developer/CommandLineTools/usr/lib/clang/12.0.0/include/mmintrin.h:287:19: error: use of undeclared identifier '__builtin_ia32_punpcklbw'
    return (__m64)__builtin_ia32_punpcklbw((__v8qi)__m1, (__v8qi)__m2);
                  ^
/Library/Developer/CommandLineTools/usr/lib/clang/12.0.0/include/mmintrin.h:310:19: error: use of undeclared identifier '__builtin_ia32_punpcklwd'
    return (__m64)__builtin_ia32_punpcklwd((__v4hi)__m1, (__v4hi)__m2);
                  ^
/Library/Developer/CommandLineTools/usr/lib/clang/12.0.0/include/mmintrin.h:331:19: error: use of undeclared identifier '__builtin_ia32_punpckldq'
    return (__m64)__builtin_ia32_punpckldq((__v2si)__m1, (__v2si)__m2);
                  ^
/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'?
    return (__m64)__builtin_ia32_paddb((__v8qi)__m1, (__v8qi)__m2);
                  ^
/Library/Developer/CommandLineTools/usr/lib/clang/12.0.0/include/mmintrin.h:352:19: note: '__builtin_arm_addg' declared here
/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)
    return (__m64)__builtin_ia32_paddb((__v8qi)__m1, (__v8qi)__m2);
                  ^                    ~~~~~~~~~~~~
/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'?
    return (__m64)__builtin_ia32_paddw((__v4hi)__m1, (__v4hi)__m2);
                  ^
/Library/Developer/CommandLineTools/usr/lib/clang/12.0.0/include/mmintrin.h:352:19: note: '__builtin_arm_addg' declared here
    return (__m64)__builtin_ia32_paddb((__v8qi)__m1, (__v8qi)__m2);
                  ^
/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)
    return (__m64)__builtin_ia32_paddw((__v4hi)__m1, (__v4hi)__m2);
                  ^                    ~~~~~~~~~~~~
/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'?
    return (__m64)__builtin_ia32_paddd((__v2si)__m1, (__v2si)__m2);
                  ^
/Library/Developer/CommandLineTools/usr/lib/clang/12.0.0/include/mmintrin.h:352:19: note: '__builtin_arm_addg' declared here
    return (__m64)__builtin_ia32_paddb((__v8qi)__m1, (__v8qi)__m2);
                  ^
/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)
    return (__m64)__builtin_ia32_paddd((__v2si)__m1, (__v2si)__m2);
                  ^                    ~~~~~~~~~~~~
fatal error: too many errors emitted, stopping now [-ferror-limit=]
20 errors generated.
make: *** [Release/obj.target/metrohash/src/metrohash128crc.o] Error 1
gyp ERR! build error
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack     at ChildProcess.onExit (/Users/johndoe/Projects/my-project/node_modules/node-gyp/lib/build.js:262:23)
gyp ERR! stack     at ChildProcess.emit (node:events:378:20)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (node:internal/child_process:290:12)
gyp ERR! System Darwin 20.3.0
gyp 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"
gyp ERR! cwd /Users/johndoe/Projects/my-project/node_modules/metrohash

我在用着

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

到目前为止我尝试过的

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

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

任何帮助深表感谢。

请比较 node-sass 版本和你的 node 版本

在此处输入图像描述

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

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

我在 macOS 12.1 Monterey 上遇到了同样的问题,这是由 node-sass-chokidar 引起的。 当我从较旧的 NodeJS 切换到版本 16 LTS 时,我遇到了这个问题。

为了解决这个问题,我:

  1. 从 package.json 中删除了 node-sass-chokidar
  2. 删除了 node_modules
  3. 安装了纱线
  4. 添加 node-sass 与 yarn 添加 node-sass

我还需要在 package.json 的“脚本”中更改这些行。

从:

"build-css": "node-sass-chokidar --include-path./src --include-path./node_modules src/ -o src/", "watch-css": "npm run build-css && node -sass-chokidar --include-path./src --include-path./node_modules src/ -o src/ --watch --recursive",

至:

"build-css": "node-sass --include-path./src --include-path./node_modules src/ -o src/", "watch-css": "npm run build-css && node-sass --include-path./src --include-path./node_modules src/ -o src/ --watch --recursive",

之后,一切都运行良好。 关于使用 node-sass 而不是 node-sass-chokidar ( https://pretagteam.com/question/remove-nodesass-from-my-react-project-which-uses-createreactapp ) 的效率的讨论只是为了完整性,但是它似乎没有影响我的设置。

使用 nvm 将节点版本从 v17.3.0 降级到 v14.18.3 后,解决了我在新 Macbook air M1 笔记本电脑上的问题。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM