开发者问题收集

部署 Firebase Cloud Functions 时出错

2019-12-01
2446

我在部署云功能时遇到了 @grpc/grpc-js only works on Node ^8.13.0 || >=10.10.0 错误。我安装了 nvm 并将节点更新到 12.13.1,使用 firebase 工具版本 7.8.1。我再次运行 npm install 并重新部署我的云功能,然后出现以下错误消息:

Error: Error parsing triggers: Cannot find module 'firebase'

Require stack:

  • /Users/chriscynn/Desktop/pretzly/pretzly/functions/index.js

  • /usr/local/lib/node_modules/firebase-tools/lib/triggerParser.js

我理解这意味着 node_modules 文件夹中的 firebase 模块不存在,这是真的。所以我输入了 npm install firebase 命令,并在最底部粘贴了完整的打印内容。

任何帮助都将不胜感激,过去几天一直在辛苦工作 - 清除、安装、重新安装、卸载等 - 并且在解决问题时找不到一线希望。我对编程还很陌生,对 CLI 的理解更差。

我当前的 package.json 是……

在此处输入图片描述

CLI npm install firebase 错误日志

1. [email protected] install /Users/me/Desktop/appName/appName/functions/node_modules/grpc

node-pre-gyp install --fallback-to-build --library=static_library

node-pre-gyp WARN Using needle 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-darwin-x64-unknown.tar.gz

node-pre-gyp WARN Pre-built binaries not found for [email protected] and [email protected] (node-v72 ABI, unknown) (falling back to source compile with node-gyp)

2. Rows of "CXX(target) Release/obj.target..." print out

3. ../ext/channel.cc:292:56: error: too few arguments to function call, expected 2, have 1
int try_to_connect = (int)info[0]->Equals(Nan::True());

/Users/me/Library/Caches/node-gyp/12.13.1/include/node/v8.h:2616:3: note: 'Equals' declared here V8_WARN_UNUSED_RESULT Maybe Equals(Local context,

/Users/me/Library/Caches/node-gyp/12.13.1/include/node/v8config.h:351:31: note: expanded from macro 'V8_WARN_UNUSED_RESULT' define V8_WARN_UNUSED_RESULT attribute((warn_unused_result))

1 error generated.

make: *** [Release/obj.target/grpc_node/ext/channel.o] Error 1

gyp ERR! build error

gyp ERR! stack Error: make failed with exit code: 2

gyp ERR! stack at ChildProcess.onExit (/usr/local/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 Darwin 18.7.0

gyp ERR! command "/usr/local/bin/node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "build" "--fallback-to-build" "--library=static_library" "--module=/Users/me/Desktop/appName/appName/functions/node_modules/grpc/src/node/extension_binary/node-v72-darwin-x64-unknown/grpc_node.node" "--module_name=grpc_node" "--module_path=/Users/me/Desktop/appName/appName/functions/node_modules/grpc/src/node/extension_binary/node-v72-darwin-x64-unknown" "--napi_version=5" "--node_abi_napi=napi" "--napi_build_version=0" "--node_napi_label=node-v72"

gyp ERR! cwd /Users/me/Desktop/appName/appName/functions/node_modules/grpc

gyp ERR! node -v v12.13.1

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 '/usr/local/bin/node /usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js build --fallback-to-build --library=static_library --module=/Users/me/Desktop/appName/appName/functions/node_modules/grpc/src/node/extension_binary/node-v72-darwin-x64-unknown/grpc_node.node --module_name=grpc_node --module_path=/Users/me/Desktop/appName/appName/functions/node_modules/grpc/src/node/extension_binary/node-v72-darwin-x64-unknown --napi_version=5 --node_abi_napi=napi --napi_build_version=0 --node_napi_label=node-v72' (1)

node-pre-gyp ERR! stack at ChildProcess. (/Users/me/Desktop/appName/appName/functions/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 Darwin 18.7.0

node-pre-gyp ERR! command "/usr/local/bin/node" "/Users/me/Desktop/appName/appName/functions/node_modules/grpc/node_modules/.bin/node-pre-gyp" "install" "--fallback-to-build" "--library=static_library"

node-pre-gyp ERR! cwd /Users/me/Desktop/appName/appName/functions/node_modules/grpc

node-pre-gyp ERR! node -v v12.13.1

node-pre-gyp ERR! node-pre-gyp -v v0.12.0

node-pre-gyp ERR! not ok

Failed to execute '/usr/local/bin/node /usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js build --fallback-to-build --library=static_library --module=/Users/me/Desktop/appName/appName/functions/node_modules/grpc/src/node/extension_binary/node-v72-darwin-x64-unknown/grpc_node.node --module_name=grpc_node --module_path=/Users/me/Desktop/appName/appName/functions/node_modules/grpc/src/node/extension_binary/node-v72-darwin-x64-unknown --napi_version=5 --node_abi_napi=napi --napi_build_version=0 --node_napi_label=node-v72' (1)

npm ERR! code ELIFECYCLE

npm ERR! errno 1

npm ERR! [email protected] install: node-pre-gyp install --fallback-to-build --library=static_library

npm ERR! Exit status 1

npm ERR! Failed at the [email protected] install script.

3个回答

该日志中的问题是您正在安装 grpc 版本 1.20.0,该版本不支持 Node 12。您需要删除依赖于 grpc 的任何库,或者使用较新版本的 grpc ,或者使用较旧版本的 Node。

murgatroid99
2019-12-04

您尝试执行的所有操作都可以通过 firebase-admin 完成。不要使用其他 Firebase Web 客户端库,因为它们不适用于节点。只需删除除 firebase-admin 和 firebase-functions 之外的所有其他 firebase 依赖项即可开始使用。

Doug Stevenson
2019-12-01

首先,您需要确保删除所有冲突的 npm 版本

sudo apt-get autoremove 

其次,使用以下命令安装最新的 npm

curl -sL https://deb.nodesource.com/setup_14.x | sudo -E bash - 

然后

sudo apt-get install -y nodejs

这是针对 Debian 发行版的,对于其他操作系统,请查看此链接: https://nodejs.org/en/download/package-manager/#debian-and-ubuntu-based-linux-distributions-enterprise-linux-fedora-and-snap-packages

或者,您也可以使用

sudo npm install -g npm@latest

或者对于版本 8.13.0,特别是

 sudo npm install -g [email protected]
Jay Shenawy
2020-06-18