Web Developer
I followed the guide for initiating and deploying a function using the CLI from a folder called "appwrite_functions" where my Appwrite.json resides. My first function called "inviteEmail" resides in "appwrite_functions > functions > inviteEmail" which is a folder that contains the automatically generated files by Appwrite init function (src folder with index.js, and package.json). I deployed the function by running the "appwrite function createDeployment" with correct ID and --entrypoint="src/index.js". The build is successful. I am running Appwrite locally on http://localhost/v1.
But when I execute the function manually from Appwrite Console I get the error below. I really cannot understand what the problem is. I have tried editing the entrypoint to --entrypoint="index.js" and to --entrypoint="inviteEmail/src/index.js" in the CLI command. But with the same error on execution. The file "appwrite.json" has these parameters related to the path and entrypoint:
"path": "functions/inviteEmail",
"entrypoint": "src/index.js",
Error: Cannot find module '/usr/code-start/src/index.js'
Require stack:
- /usr/local/src/server.js
at Function.Module._resolveFilename (node:internal/modules/cjs/loader:940:15)
at Module.Hook._require.Module.require (/usr/local/lib/node_modules/pm2/node_modules/require-in-the-middle/index.js:81:25)
at require (node:internal/modules/cjs/helpers:93:18)
at /usr/local/src/server.js:55:28
at processTicksAndRejections (node:internal/process/task_queues:96:5)