Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

gCloud: File index.js does not exist in root directory

I am a first time user of Gcloud. When I run the following command:

gcloud beta functions deploy FirstBot --stage-bucket [BUCKET_NAME] --trigger-http

I'm getting this error in my cmd:

ERROR: (gcloud.beta.functions.deploy) OperationError: code=3, message=Function l
oad error: File index.js or function.js that is expected to define function does
n't exist in the root directory.

I have tried 2 index.js files: Here's no.1:

   /*
 HTTP Cloud Function.

 @param {Object} req Cloud Function request context.
 @param {Object} res Cloud Function response context.
*/
exports.FirstBot = function FirstBot (req, res) {
  response = "This is a sample response from your webhook!" //Default response from the webhook to show it's working

res.setHeader('Content-Type', 'application/json'); //Requires application/json MIME type
  res.send(JSON.stringify({ "speech": response, "displayText": response 
  //"speech" is the spoken version of the response, "displayText" is the visual version
  }));
};

Here's the second one:

/
 HTTP Cloud Function.

 @param {Object} req Cloud Function request context.
 @param {Object} res Cloud Function response context.
*/
exports.helloHttp = function helloHttp (req, res) {
  response = "This is a sample response from your webhook!" //Default response from the webhook to show it's working

res.setHeader('Content-Type', 'application/json'); //Requires application/json MIME type
  res.send(JSON.stringify({ "speech": response, "displayText": response 
  //"speech" is the spoken version of the response, "displayText" is the visual version
  }));
};

The name of my project is FirstBot. I have created a bucket also.

The path of my FirstBot folder is C:\FirstBot. The index.js file is inside it. I am following the tutorial at: https://api.ai/docs/getting-started/basic-fulfillment-conversation

Kindly help..Would be grateful!

like image 397
Maverick7 Avatar asked Jan 04 '23 16:01

Maverick7


1 Answers

Is the file in your .gitignore? If a .gcloudignore isn't specified, the .gitignore is used to ignore files.

Adding an empty .gcloudignore should fix this.

like image 198
0xcaff Avatar answered Jan 17 '23 13:01

0xcaff