Ubuntu 18.04 中的 `node-pre-gyp install` 相关错误
`node-pre-gyp install` related error in Ubuntu 18.04
我正尝试在我的 Ubuntu 18.04 系统中开始处理 Angular 项目,但是 npm i
命令在打印以下内容后失败:
../ext/channel.cc: In static member function ‘static Nan::NAN_METHOD_RETURN_TYPE grpc::node::Channel::GetConnectivityState(Nan::NAN_METHOD_ARGS_TYPE)’:
../ext/channel.cc:292:56: error: no matching function for call to ‘v8::Value::Equals(v8::Local<v8::Boolean>)’
int try_to_connect = (int)info[0]->Equals(Nan::True());
^
In file included from /home/asghwor/.cache/node-gyp/12.14.0/include/node/node.h:63:0,
from ../../nan/nan.h:58,
from ../ext/channel.cc:23:
/home/asghwor/.cache/node-gyp/12.14.0/include/node/v8.h:2616:37: note: candidate: v8::Maybe<bool> v8::Value::Equals(v8::Local<v8::Context>, v8::Local<v8::Value>) const
V8_WARN_UNUSED_RESULT Maybe<bool> Equals(Local<Context> context,
^~~~~~
/home/asghwor/.cache/node-gyp/12.14.0/include/node/v8.h:2616:37: note: candidate expects 2 arguments, 1 provided
At global scope:
cc1plus: error: unrecognized command line option ‘-Wno-cast-function-type’ [-Werror]
cc1plus: all warnings being treated as errors
grpc_node.target.mk:188: recipe for target 'Release/obj.target/grpc_node/ext/channel.o' failed
make: *** [Release/obj.target/grpc_node/ext/channel.o] Error 1
make: Leaving directory '/home/asghwor/Dados/company/My-Project/node_modules/grpc/build'
gyp ERR! build error
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack at ChildProcess.onExit (/home/asghwor/.nvm/versions/node/v12.14.0/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:194:23)
gyp ERR! stack at ChildProcess.emit (events.js:210:5)
gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:272:12)
gyp ERR! System Linux 5.4.0-90-generic
gyp ERR! command "/home/asghwor/.nvm/versions/node/v12.14.0/bin/node" "/home/asghwor/.nvm/versions/node/v12.14.0/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "build" "--fallback-to-build" "--library=static_library" "--module=/home/asghwor/Dados/company/My-Project/node_modules/grpc/src/node/extension_binary/node-v72-linux-x64-glibc/grpc_node.node" "--module_name=grpc_node" "--module_path=/home/asghwor/Dados/company/My-Project/node_modules/grpc/src/node/extension_binary/node-v72-linux-x64-glibc" "--napi_version=5" "--node_abi_napi=napi" "--napi_build_version=0" "--node_napi_label=node-v72"
gyp ERR! cwd /home/asghwor/Dados/company/My-Project/node_modules/grpc
gyp ERR! node -v v12.14.0
gyp ERR! node-gyp -v v5.0.5
gyp ERR! not ok
node-pre-gyp ERR! build error
node-pre-gyp ERR! stack Error: Failed to execute '/home/asghwor/.nvm/versions/node/v12.14.0/bin/node /home/asghwor/.nvm/versions/node/v12.14.0/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js build --fallback-to-build --library=static_library --module=/home/asghwor/Dados/company/My-Project/node_modules/grpc/src/node/extension_binary/node-v72-linux-x64-glibc/grpc_node.node --module_name=grpc_node --module_path=/home/asghwor/Dados/company/My-Project/node_modules/grpc/src/node/extension_binary/node-v72-linux-x64-glibc --napi_version=5 --node_abi_napi=napi --napi_build_version=0 --node_napi_label=node-v72' (1)
node-pre-gyp ERR! stack at ChildProcess.<anonymous> (/home/asghwor/Dados/company/My-Project/node_modules/grpc/node_modules/node-pre-gyp/lib/util/compile.js:83:29)
node-pre-gyp ERR! stack at ChildProcess.emit (events.js:210:5)
node-pre-gyp ERR! stack at maybeClose (internal/child_process.js:1021:16)
node-pre-gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:283:5)
node-pre-gyp ERR! System Linux 5.4.0-90-generic
node-pre-gyp ERR! command "/home/asghwor/.nvm/versions/node/v12.14.0/bin/node" "/home/asghwor/Dados/company/My-Project/node_modules/grpc/node_modules/.bin/node-pre-gyp" "install" "--fallback-to-build" "--library=static_library"
node-pre-gyp ERR! cwd /home/asghwor/Dados/company/My-Project/node_modules/grpc
node-pre-gyp ERR! node -v v12.14.0
node-pre-gyp ERR! node-pre-gyp -v v0.12.0
node-pre-gyp ERR! not ok
Failed to execute '/home/asghwor/.nvm/versions/node/v12.14.0/bin/node /home/asghwor/.nvm/versions/node/v12.14.0/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js build --fallback-to-build --library=static_library --module=/home/asghwor/Dados/company/My-Project/node_modules/grpc/src/node/extension_binary/node-v72-linux-x64-glibc/grpc_node.node --module_name=grpc_node --module_path=/home/asghwor/Dados/company/My-Project/node_modules/grpc/src/node/extension_binary/node-v72-linux-x64-glibc --napi_version=5 --node_abi_napi=napi --napi_build_version=0 --node_napi_label=node-v72' (1)
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@^1.2.2 (node_modules/chokidar/node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.13: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@~2.3.2 (node_modules/watchpack/node_modules/chokidar/node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@2.3.2: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@~2.3.2 (node_modules/karma/node_modules/chokidar/node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@2.3.2: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
npm WARN mat-select-autocomplete@1.3.0 requires a peer of @angular/common@^6.0.0-rc.0 || ^6.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN mat-select-autocomplete@1.3.0 requires a peer of @angular/core@^6.0.0-rc.0 || ^6.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN mat-select-autocomplete@1.3.0 requires a peer of @angular/animations@^6.1.10 but none is installed. You must install peer dependencies yourself.
npm WARN ng2-pdfjs-viewer@5.0.7 requires a peer of @angular/core@^8.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN ngx-quill-v2@0.0.1 requires a peer of quill@^2.0.0-dev.3 but none is installed. You must install peer dependencies yourself.
npm WARN @angular/http@7.2.1 requires a peer of @angular/core@7.2.1 but none is installed. You must install peer dependencies yourself.
npm WARN @angular/http@7.2.1 requires a peer of @angular/platform-browser@7.2.1 but none is installed. You must install peer dependencies yourself.
npm WARN pdfjs-dist@2.10.377 requires a peer of worker-loader@^3.0.7 but none is installed. You must install peer dependencies yourself.
npm WARN acorn-dynamic-import@4.0.0 requires a peer of acorn@^6.0.0 but none is installed. You must install peer dependencies yourself.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! grpc@1.20.0 install: `node-pre-gyp install --fallback-to-build --library=static_library`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the grpc@1.20.0 install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /home/asghwor/.npm/_logs/2021-11-29T13_10_35_405Z-debug.log
我正在使用 Angular 7.3.7 和 Node 12.14.0。
我无法更新项目和系统,因为这是公司强制执行的。
我可以运行这个项目做什么?
编辑:在上面的错误之前,它还打印了这个:
node-pre-gyp WARN Using request for node-pre-gyp https download
node-pre-gyp WARN Tried to download(404): https://node-precompiled-binaries.grpc.io/grpc/v1.20.0/node-v72-linux-x64-glibc.tar.gz
node-pre-gyp WARN Pre-built binaries not found for grpc@1.20.0 and node@12.14.0 (node-v72 ABI, glibc) (falling back to source compile with node-gyp)
make: Entering directory '/home/asghwor/path-to-project/node_modules/@firebase/firestore/node_modules/grpc/build'
CXX(target) Release/obj.target/grpc/deps/grpc/src/core/lib/surface/init.o
// ... and many other file.o files
确保您已安装所需的构建器:
sudo apt-get update
sudo apt-get install build-essential
如果已经完成,您可以跳过上一步。
接下来,在您的项目中删除 node_modules 文件夹,再次 运行 npm install
,但作为普通用户,您永远不应该 运行 npm 作为 root。
找到解决方案 here。这是旧版本的 Firebase 导致的。
更新到最新版本或线程中提到的版本都为我修复了它。
我正尝试在我的 Ubuntu 18.04 系统中开始处理 Angular 项目,但是 npm i
命令在打印以下内容后失败:
../ext/channel.cc: In static member function ‘static Nan::NAN_METHOD_RETURN_TYPE grpc::node::Channel::GetConnectivityState(Nan::NAN_METHOD_ARGS_TYPE)’:
../ext/channel.cc:292:56: error: no matching function for call to ‘v8::Value::Equals(v8::Local<v8::Boolean>)’
int try_to_connect = (int)info[0]->Equals(Nan::True());
^
In file included from /home/asghwor/.cache/node-gyp/12.14.0/include/node/node.h:63:0,
from ../../nan/nan.h:58,
from ../ext/channel.cc:23:
/home/asghwor/.cache/node-gyp/12.14.0/include/node/v8.h:2616:37: note: candidate: v8::Maybe<bool> v8::Value::Equals(v8::Local<v8::Context>, v8::Local<v8::Value>) const
V8_WARN_UNUSED_RESULT Maybe<bool> Equals(Local<Context> context,
^~~~~~
/home/asghwor/.cache/node-gyp/12.14.0/include/node/v8.h:2616:37: note: candidate expects 2 arguments, 1 provided
At global scope:
cc1plus: error: unrecognized command line option ‘-Wno-cast-function-type’ [-Werror]
cc1plus: all warnings being treated as errors
grpc_node.target.mk:188: recipe for target 'Release/obj.target/grpc_node/ext/channel.o' failed
make: *** [Release/obj.target/grpc_node/ext/channel.o] Error 1
make: Leaving directory '/home/asghwor/Dados/company/My-Project/node_modules/grpc/build'
gyp ERR! build error
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack at ChildProcess.onExit (/home/asghwor/.nvm/versions/node/v12.14.0/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:194:23)
gyp ERR! stack at ChildProcess.emit (events.js:210:5)
gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:272:12)
gyp ERR! System Linux 5.4.0-90-generic
gyp ERR! command "/home/asghwor/.nvm/versions/node/v12.14.0/bin/node" "/home/asghwor/.nvm/versions/node/v12.14.0/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "build" "--fallback-to-build" "--library=static_library" "--module=/home/asghwor/Dados/company/My-Project/node_modules/grpc/src/node/extension_binary/node-v72-linux-x64-glibc/grpc_node.node" "--module_name=grpc_node" "--module_path=/home/asghwor/Dados/company/My-Project/node_modules/grpc/src/node/extension_binary/node-v72-linux-x64-glibc" "--napi_version=5" "--node_abi_napi=napi" "--napi_build_version=0" "--node_napi_label=node-v72"
gyp ERR! cwd /home/asghwor/Dados/company/My-Project/node_modules/grpc
gyp ERR! node -v v12.14.0
gyp ERR! node-gyp -v v5.0.5
gyp ERR! not ok
node-pre-gyp ERR! build error
node-pre-gyp ERR! stack Error: Failed to execute '/home/asghwor/.nvm/versions/node/v12.14.0/bin/node /home/asghwor/.nvm/versions/node/v12.14.0/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js build --fallback-to-build --library=static_library --module=/home/asghwor/Dados/company/My-Project/node_modules/grpc/src/node/extension_binary/node-v72-linux-x64-glibc/grpc_node.node --module_name=grpc_node --module_path=/home/asghwor/Dados/company/My-Project/node_modules/grpc/src/node/extension_binary/node-v72-linux-x64-glibc --napi_version=5 --node_abi_napi=napi --napi_build_version=0 --node_napi_label=node-v72' (1)
node-pre-gyp ERR! stack at ChildProcess.<anonymous> (/home/asghwor/Dados/company/My-Project/node_modules/grpc/node_modules/node-pre-gyp/lib/util/compile.js:83:29)
node-pre-gyp ERR! stack at ChildProcess.emit (events.js:210:5)
node-pre-gyp ERR! stack at maybeClose (internal/child_process.js:1021:16)
node-pre-gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:283:5)
node-pre-gyp ERR! System Linux 5.4.0-90-generic
node-pre-gyp ERR! command "/home/asghwor/.nvm/versions/node/v12.14.0/bin/node" "/home/asghwor/Dados/company/My-Project/node_modules/grpc/node_modules/.bin/node-pre-gyp" "install" "--fallback-to-build" "--library=static_library"
node-pre-gyp ERR! cwd /home/asghwor/Dados/company/My-Project/node_modules/grpc
node-pre-gyp ERR! node -v v12.14.0
node-pre-gyp ERR! node-pre-gyp -v v0.12.0
node-pre-gyp ERR! not ok
Failed to execute '/home/asghwor/.nvm/versions/node/v12.14.0/bin/node /home/asghwor/.nvm/versions/node/v12.14.0/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js build --fallback-to-build --library=static_library --module=/home/asghwor/Dados/company/My-Project/node_modules/grpc/src/node/extension_binary/node-v72-linux-x64-glibc/grpc_node.node --module_name=grpc_node --module_path=/home/asghwor/Dados/company/My-Project/node_modules/grpc/src/node/extension_binary/node-v72-linux-x64-glibc --napi_version=5 --node_abi_napi=napi --napi_build_version=0 --node_napi_label=node-v72' (1)
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@^1.2.2 (node_modules/chokidar/node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.13: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@~2.3.2 (node_modules/watchpack/node_modules/chokidar/node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@2.3.2: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@~2.3.2 (node_modules/karma/node_modules/chokidar/node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@2.3.2: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
npm WARN mat-select-autocomplete@1.3.0 requires a peer of @angular/common@^6.0.0-rc.0 || ^6.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN mat-select-autocomplete@1.3.0 requires a peer of @angular/core@^6.0.0-rc.0 || ^6.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN mat-select-autocomplete@1.3.0 requires a peer of @angular/animations@^6.1.10 but none is installed. You must install peer dependencies yourself.
npm WARN ng2-pdfjs-viewer@5.0.7 requires a peer of @angular/core@^8.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN ngx-quill-v2@0.0.1 requires a peer of quill@^2.0.0-dev.3 but none is installed. You must install peer dependencies yourself.
npm WARN @angular/http@7.2.1 requires a peer of @angular/core@7.2.1 but none is installed. You must install peer dependencies yourself.
npm WARN @angular/http@7.2.1 requires a peer of @angular/platform-browser@7.2.1 but none is installed. You must install peer dependencies yourself.
npm WARN pdfjs-dist@2.10.377 requires a peer of worker-loader@^3.0.7 but none is installed. You must install peer dependencies yourself.
npm WARN acorn-dynamic-import@4.0.0 requires a peer of acorn@^6.0.0 but none is installed. You must install peer dependencies yourself.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! grpc@1.20.0 install: `node-pre-gyp install --fallback-to-build --library=static_library`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the grpc@1.20.0 install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /home/asghwor/.npm/_logs/2021-11-29T13_10_35_405Z-debug.log
我正在使用 Angular 7.3.7 和 Node 12.14.0。
我无法更新项目和系统,因为这是公司强制执行的。
我可以运行这个项目做什么?
编辑:在上面的错误之前,它还打印了这个:
node-pre-gyp WARN Using request for node-pre-gyp https download
node-pre-gyp WARN Tried to download(404): https://node-precompiled-binaries.grpc.io/grpc/v1.20.0/node-v72-linux-x64-glibc.tar.gz
node-pre-gyp WARN Pre-built binaries not found for grpc@1.20.0 and node@12.14.0 (node-v72 ABI, glibc) (falling back to source compile with node-gyp)
make: Entering directory '/home/asghwor/path-to-project/node_modules/@firebase/firestore/node_modules/grpc/build'
CXX(target) Release/obj.target/grpc/deps/grpc/src/core/lib/surface/init.o
// ... and many other file.o files
确保您已安装所需的构建器:
sudo apt-get update
sudo apt-get install build-essential
如果已经完成,您可以跳过上一步。
接下来,在您的项目中删除 node_modules 文件夹,再次 运行 npm install
,但作为普通用户,您永远不应该 运行 npm 作为 root。
找到解决方案 here。这是旧版本的 Firebase 导致的。
更新到最新版本或线程中提到的版本都为我修复了它。