Back

Can't Seem To Run Functions in NODEJS Env

  • 0
  • Functions
  • Web
ksebiloane
16 Aug, 2023, 10:18

so i created a simple sendEmail function in my nodeJS env, it all works locally when I try to deploy the code to an appwrite function, I get the following error

TypeError: userFunction is not a function at /usr/local/src/server.js:68:19 at processTicksAndRejections (node:internal/process/task_queues:96:5)

I check the folder, structure I made use I uploaded it in the right folder structure along with all dependencies the function needs to run, made sure it is pointing to the right place, but I don't know how to resolve this

I am not sure I need to give anymore information than this but if I do I am more than happy to

TL;DR
Issue: Unable to run functions in NODEJS environment. Getting "TypeError: userFunction is not a function" error when deploying to Appwrite function. Possible Solutions: 1. Check the function's entry point and ensure it is correct. 2. Verify that the function is being exported correctly using either `module.exports` or `exports` syntax. 3. Double-check the `package.json` file and ensure all required dependencies are listed and uploaded alongside the function. 4. Verify the folder structure of the zipped folder and ensure it does not contain another folder. 5. Check the Appwrite logs for more details on the error or any other
joeyouss
16 Aug, 2023, 12:19
joeyouss
16 Aug, 2023, 12:21

Some additional checks:

  1. Ensure your function's entry point is correct.
  2. Ensure that you're exporting your function correctly. In Node.js, you typically use the module.exports or exports syntax to expose functions or objects to other files. For instance:
  3. Double-check your package.json file. Ensure all your required dependencies are listed and are uploaded alongside your function.
  4. Sometimes, the error might arise due to how files are zipped. The zipped folder should not contain another folder that then contains your code. It should directly contain your main JS files, other necessary files, and the node_modules directory.

And always check the logs. Appwrite provides logs. Check those logs for more details on the error or any other information that might help.

If you've gone through all these steps and are still facing the issue, please provide more information or code snippets, so we can dive deeper into the problem.

ksebiloane
17 Aug, 2023, 09:17

okay thank you so much let me look into this, i appreciate the help

safwan
17 Aug, 2023, 09:54

If you aren't able to fix the issue, feel free to share your function code to see if there's an issue!

Reply

Reply to this thread by joining our Discord

Reply on Discord

Need support?

Join our Discord

Get community support by joining our Discord server.

Join Discord

Get premium support

Join Appwrite Pro and get email support from our team.

Learn more