0

I am attempting to run through the introduction to Google Cloud Pub/Sub Triggers. When running the example code:

gcloud functions deploy publish --runtime nodejs8 --trigger-http

I get the following error:

ERROR: (gcloud.functions.deploy) OperationError: code=3, message=Function failed on loading user code. Error message: Node.js module defined by file index.js is expected to export function named publish

The logs on stackdriver show:

D 2019-11-18T23:53:41.689Z publish Node.js module defined by file index.js is expected to export function named publish  
E 2019-11-18T23:53:41.761Z Cloud Functions CreateFunction us-central1:publish <email> INVALID_ARGUMENT Cloud Functions CreateFunction us-central1:publish <email> 
E 2019-11-18T23:54:15.667Z Cloud Functions UpdateFunction us-central1:publish <email> FAILED_PRECONDITION Cloud Functions UpdateFunction us-central1:publish <email> 

1 Answer 1

1

Turns out I was attempting to deploy from the wrong directory. The correct index.js file included the function definition, and allowed successful deployment of the function.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.