1

I'm trying to deploy the Google Assisant SDK in Node.js to a Google Cloud Function but running into this error..

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

From searching online, it looks like I need to rebuild with a specific binary. So in my package.json I added this, but that doesn't seem to have done anything. To deploy I'm simply zipping everything up and uploading it to the Google Cloud Function interface. Any ideas?

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

Ray
  • 325
  • 4
  • 15
  • Are you doing the rebuild on your local machine or just putting that script in your Cloud Function? I don't think these scripts run in a Cloud Function environment. – Nick Felker Apr 13 '20 at 15:28
  • @NickFelker, Worked locally but on the Cloud Function I'm just uploading a .zip file with the script in the `package.json`. Ah didnt know the script wouldnt run.. any other way I can do a rebuild on the Cloud Function deploy? – Ray Apr 14 '20 at 18:05
  • Don't these zip files include the `node_modules` you want to use? – Nick Felker Apr 14 '20 at 22:15

0 Answers0