I am deploying a simple function on Google Cloud Functions but I am getting a Function cannot be initialized. Error: function terminated. Recommended action: inspect logs for termination reason.
error.
This is my code:
index.js
require('dotenv').config();
const crypto = require('crypto');
const {
Octokit
} = require("@octokit/core");
const moment = require('moment');
const myFunc = (req, res) => {
// My Code
}
package.json
{
"name": "Test",
"version": "1.0.0",
"description": "Test",
"main": "index.js",
"scripts": {
"start": "node index.js"
},
"author": "jane doe",
"license": "MIT",
"dependencies": {
"@octokit/core": "^4.1.0",
"dotenv": "^16.0.3",
"moment": "^2.29.4"
}
}
Other files are:
- .env file to set environment variables
- package-lock.json
- node_modules folder
I am deploying using the UI, and have set the entry point to myFunc
.
My deployment is unsuccessful when doing it this way and this is what my error logs say:
Function 'myFunc' is not defined in the provided module.
Did you specify the correct target function to execute?
Could not load the function, shutting down.
Function cannot be initialized. Error: function terminated. Recommended action: inspect logs for termination reason.
What am I missing here?