node-gyp“错误:在m2 pro上安装npm时,“make”失败,退出代码为”

plicqrtu  于 2023-10-19  发布在  其他
关注(0)|答案(1)|浏览(241)

我刚刚购买了一台MacBook M2 Pro,并试图运行我的一个旧Vue项目,节点为v19.6.0和npm 6.14.18。在进行npm安装时,我收到了2个错误,似乎与使用其他包(如[[email protected]](https://stackoverflow.com/cdn-cgi/l/email-protection)[[email protected]](https://stackoverflow.com/cdn-cgi/l/email-protection))构建node-gyp有关。

*fibers错误看起来像这样:

> [email protected] install /Users/user1/Projects/project1/frontend/node_modules/fibers
> node build.js || nodejs build.js

CXX(target) Release/obj.target/fibers/src/fibers.o
../src/fibers.cc:27:65: error: no member named 'kFinalizer' in 'v8::WeakCallbackType'
              handle.SetWeak(val, WeakCallbackShim<F, P>, WeakCallbackType::kFinalizer);
                                                          ~~~~~~~~~~~~~~~~~~^
1 error generated.
make: *** [Release/obj.target/fibers/src/fibers.o] Error 1
gyp ERR! build error 
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack     at ChildProcess.onExit (/Users/user1/.nvm/versions/node/v19.6.0/lib/node_modules/npm/node_modules/npm-lifecycle/node_modules/node-gyp/lib/build.js:203:23)
gyp ERR! stack     at ChildProcess.emit (node:events:512:28)
gyp ERR! stack     at ChildProcess._handle.onexit (node:internal/child_process:293:12)
gyp ERR! System Darwin 22.1.0
gyp ERR! command "/Users/user1/.nvm/versions/node/v19.6.0/bin/node" "/Users/user1/.nvm/versions/node/v19.6.0/lib/node_modules/npm/node_modules/npm-lifecycle/node_modules/node-gyp/bin/node-gyp.js" "rebuild" "--release"
gyp ERR! cwd /Users/user1/Projects/project1/frontend/node_modules/fibers
gyp ERR! node -v v19.6.0
gyp ERR! node-gyp -v v9.3.1
gyp ERR! not ok 
node-gyp exited with code: 1

*fsevents错误看起来像这样:

node-pre-gyp WARN Using request for node-pre-gyp https download 
node-pre-gyp WARN Tried to download(403): https://fsevents-binaries.s3-us-west-2.amazonaws.com/v1.2.9/fse-v1.2.9-node-v111-darwin-arm64.tar.gz 
node-pre-gyp WARN Pre-built binaries not found for [email protected] and [email protected] (node-v111 ABI, unknown) (falling back to source compile with node-gyp) 
 SOLINK_MODULE(target) Release/.node
 CXX(target) Release/obj.target/fse/fsevents.o
In file included from ../fsevents.cc:6:
In file included from ../../nan/nan.h:174:
../../nan/nan_callbacks.h:55:23: error: no member named 'AccessorSignature' in namespace 'v8'
typedef v8::Local<v8::AccessorSignature> Sig;
                 ~~~~^
In file included from ../fsevents.cc:6:
../../nan/nan.h:2536:8: error: no matching member function for call to 'SetAccessor'
 tpl->SetAccessor(
 ~~~~~^~~~~~~~~~~
/Users/user1/Library/Caches/node-gyp/19.6.0/include/node/v8-template.h:814:8: note: candidate function not viable: no known conversion from 'imp::Sig' (aka 'int') to 'v8::SideEffectType' for 7th argument
 void SetAccessor(
      ^
/Users/user1/Library/Caches/node-gyp/19.6.0/include/node/v8-template.h:807:8: note: candidate function not viable: no known conversion from 'imp::NativeGetter' (aka 'void (*)(v8::Local<v8::Name>, const v8::PropertyCallbackInfo<v8::Value> &)') to 'v8::AccessorGetterCallback' (aka 'void (*)(Local<v8::String>, const PropertyCallbackInfo<v8::Value> &)') for 2nd argument
 void SetAccessor(
      ^
In file included from ../fsevents.cc:6:
In file included from ../../nan/nan.h:2884:
../../nan/nan_typedarray_contents.h:34:43: error: no member named 'GetContents' in 'v8::ArrayBuffer'
     data   = static_cast<char*>(buffer->GetContents().Data()) + byte_offset;
                                 ~~~~~~~~^
3 errors generated.
make: *** [Release/obj.target/fse/fsevents.o] Error 1
gyp ERR! build error 
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack     at ChildProcess.onExit (/Users/user1/.nvm/versions/node/v19.6.0/lib/node_modules/npm/node_modules/npm-lifecycle/node_modules/node-gyp/lib/build.js:203:23)
gyp ERR! stack     at ChildProcess.emit (node:events:512:28)
gyp ERR! stack     at ChildProcess._handle.onexit (node:internal/child_process:293:12)
gyp ERR! System Darwin 22.1.0
gyp ERR! command "/Users/user1/.nvm/versions/node/v19.6.0/bin/node" "/Users/user1/.nvm/versions/node/v19.6.0/lib/node_modules/npm/node_modules/npm-lifecycle/node_modules/node-gyp/bin/node-gyp.js" "build" "--fallback-to-build" "--module=/Users/user1/Projects/project1/frontend/node_modules/fsevents/lib/binding/Release/node-v111-darwin-arm64/fse.node" "--module_name=fse" "--module_path=/Users/user1/Projects/project1/frontend/node_modules/fsevents/lib/binding/Release/node-v111-darwin-arm64" "--napi_version=8" "--node_abi_napi=napi" "--napi_build_version=0" "--node_napi_label=node-v111"
gyp ERR! cwd /Users/user1/Projects/project1/frontend/node_modules/fsevents
gyp ERR! node -v v19.6.0
gyp ERR! node-gyp -v v9.3.1
gyp ERR! not ok 
node-pre-gyp ERR! build error 
node-pre-gyp ERR! stack Error: Failed to execute '/Users/user1/.nvm/versions/node/v19.6.0/bin/node /Users/user1/.nvm/versions/node/v19.6.0/lib/node_modules/npm/node_modules/npm-lifecycle/node_modules/node-gyp/bin/node-gyp.js build --fallback-to-build --module=/Users/user1/Projects/project1/frontend/node_modules/fsevents/lib/binding/Release/node-v111-darwin-arm64/fse.node --module_name=fse --module_path=/Users/user1/Projects/project1/frontend/node_modules/fsevents/lib/binding/Release/node-v111-darwin-arm64 --napi_version=8 --node_abi_napi=napi --napi_build_version=0 --node_napi_label=node-v111' (1)
node-pre-gyp ERR! stack     at ChildProcess.<anonymous> (/Users/user1/Projects/project1/frontend/node_modules/fsevents/node_modules/node-pre-gyp/lib/util/compile.js:83:29)
node-pre-gyp ERR! stack     at ChildProcess.emit (node:events:512:28)
node-pre-gyp ERR! stack     at maybeClose (node:internal/child_process:1098:16)
node-pre-gyp ERR! stack     at ChildProcess._handle.onexit (node:internal/child_process:304:5)
node-pre-gyp ERR! System Darwin 22.1.0
node-pre-gyp ERR! command "/Users/user1/.nvm/versions/node/v19.6.0/bin/node" "/Users/user1/Projects/project1/frontend/node_modules/fsevents/node_modules/node-pre-gyp/bin/node-pre-gyp" "install" "--fallback-to-build"
node-pre-gyp ERR! cwd /Users/user1/Projects/project1/frontend/node_modules/fsevents
node-pre-gyp ERR! node -v v19.6.0
node-pre-gyp ERR! node-pre-gyp -v v0.12.0
node-pre-gyp ERR! not ok 
Failed to execute '/Users/user1/.nvm/versions/node/v19.6.0/bin/node /Users/user1/.nvm/versions/node/v19.6.0/lib/node_modules/npm/node_modules/npm-lifecycle/node_modules/node-gyp/bin/node-gyp.js build --fallback-to-build --module=/Users/user1/Projects/project1/frontend/node_modules/fsevents/lib/binding/Release/node-v111-darwin-arm64/fse.node --module_name=fse --module_path=/Users/user1/Projects/project1/frontend/node_modules/fsevents/lib/binding/Release/node-v111-darwin-arm64 --napi_version=8 --node_abi_napi=napi --napi_build_version=0 --node_napi_label=node-v111' (1)

我已经按照这里的说明https://github.com/nodejs/node-gyp#on-macos安装node-gyp,但仍然得到这个错误。
有没有人见过这个问题,或者知道如何解决这个问题?

aurhwmvo

aurhwmvo1#

我能够通过将nodejs从v20.1.0回滚到v18.18.0(当时的lts版本)来修复这个问题。

相关问题