1

我正在尝试将 Node.js 中的 Google Assisant SDK 部署到 Google Cloud Function 但遇到此错误。

Deployment failure:
Function failed on loading user code. Error message: Code in file index.js can't be loaded.
Did you list all required modules in the package.json dependencies?
Detailed stack trace: Error: Failed to load gRPC binary module because it was not installed for the current system
Expected directory: node-v57-linux-x64-glibc
Found: [node-v64-darwin-x64-unknown]
This problem can often be fixed by running "npm rebuild" on the current system
Original error: Cannot find module '/srv/google-assistant-grpc/node_modules/grpc/src/node/extension_binary/node-v57-linux-x64-glibc/grpc_node.node'
at Object.<anonymous> (/srv/google-assistant-grpc/node_modules/grpc/src/grpc_extension.js:53:17)
at Module._compile (module.js:653:30)
at Object.Module._extensions..js (module.js:664:10)
at Module.load (module.js:566:32)
at tryModuleLoad (module.js:506:12)
at Function.Module._load (module.js:498:3)
at Module.require (module.js:597:17)
at require (internal/module.js:11:18)
at Object.<anonymous> (/srv/google-assistant-grpc/node_modules/grpc/src/client_interceptors.js:144:12)
at Module._compile (module.js:653:30

从网上搜索,看来我需要使用特定的二进制文件进行重建。所以在我的package.json我添加了这个,但这似乎没有做任何事情。要部署,我只需将所有内容压缩并将其上传到 Google Cloud Function 界面。有任何想法吗?

    "scripts": {
      "postinstall": "npm rebuild --target=8.1.0 --target_platform=linux --target_arch=x64 --target_libc=glibc --update-binary"
    }

4

0 回答 0