Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to deploy to GCF #5

Closed
pgoodjohn opened this issue Dec 6, 2018 · 5 comments
Closed

Unable to deploy to GCF #5

pgoodjohn opened this issue Dec 6, 2018 · 5 comments

Comments

@pgoodjohn
Copy link

I followed the instructions described in the README, but I can't get the app to deploy on our Google Cloud Functions environment.

My handler.js file is:

const serverless = require('@probot/serverless-gcf');
const appFn = require('./')
module.exports.probot = serverless(appFn)

I've been trying to deploy it using the gcloud CLI:

gcloud --project=${GCLOUD_PROJECT} functions deploy ${PROJECT_NAME} --entry-point=probot --trigger-http --region=europe-west1 --runtime nodejs8

Running the above results in gcloud trying to deploy the app and returning the following error:

Deploying function (may take a while - up to 2 minutes)...failed.
ERROR: (gcloud.functions.deploy) OperationError: code=3, message=Function load error: Node.js module defined by file index.js is expected to export function named probot

I tried changing the entry point to handler.js by adding the following line in my package.json:

"main": "handler.js"

But I get the following error:

gcloud.functions.deploy) OperationError: code=3, message=Function load error: Code in file handler.js can't be loaded.
Is there a syntax error in your code?
Detailed stack trace: TypeError: serverless is not a function

Full Stacktrace: https://pastebin.com/m52p2PEL

Any idea what might I be missing?

@JasonEtco
Copy link
Member

Hey @pgoodjohn 👋 This is due to an error in the README that I've just corrected in 7f7a964; namely, serverless is a named export of serverless-gcf.

- const serverless = require('serverless-gcf')
+ const { serverless } = require('serverless-gcf')

Sorry about the trouble, and I appreciate you details in the issue! Helped narrow down what was going wrong. Feel free to close this issue if this is indeed the fix!

@pgoodjohn
Copy link
Author

Thanks a lot, @JasonEtco! That indeed fixed the problem.

Closing the issue.

@rthadur
Copy link

rthadur commented Feb 4, 2019

Hi
I deployed to GCF , iam getting following error :

TypeError: appFn is not a function  

can you please assist

@JasonEtco
Copy link
Member

@rthadur you may have forgotten to export the function that you are requiring. Hard to know more without seeing code; I suggest you ask for help in our Slack channel!

@pras7430
Copy link

pras7430 commented Sep 1, 2020

Hi @JasonEtco ,

this is the serverless.yml

Screenshot 2020-09-01 at 3 33 45 PM

index.js

`const express = require('express')
const { serverless } = require("@probot/serverless-gcf");

const app = express()
app.get('/', async (req, res, next) => {
res.status(200).send('Hello World!')
})
module.exports.server = serverless(app)`

getting below error

Error: Deployment failed: RESOURCE_ERROR

   {"ResourceType":"gcp-types/cloudfunctions-v1:projects.locations.functions","ResourceErrorCode":"400","ResourceErrorMessage":"Function failed on loading user code. Error message: Code in file index.js can't be loaded.\nDid you list all required modules in the package.json dependencies?\nDetailed stack trace: Error: Cannot find module 'probot'\n    at Function.Module._resolveFilename (module.js:548:15)\n    at Function.Module._load (module.js:475:25)\n    at Module.require (module.js:597:17)\n    at require (internal/module.js:11:18)\n    at Object.<anonymous> (/srv/node_modules/@probot/serverless-gcf/index.js:1:88)\n    at Module._compile (module.js:653:30)\n    at Object.Module._extensions..js (module.js:664:10)\n    at Module.load (module.js:566:32)\n    at tryModuleLoad (module.js:506:12)\n    at Function.Module._load (module.js:498:3)"}
  at throwErrorIfDeploymentFails (/Users/pras7430/my-service/node_modules/serverless-google-cloudfunctions/shared/monitorDeployment.js:71:11)
  at /Users/pras7430/my-service/node_modules/serverless-google-cloudfunctions/shared/monitorDeployment.js:42:17
  at processTicksAndRejections (internal/process/task_queues.js:97:5)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants