I'm not sure if I'm doing anything wrong with the syntax. I've copied one of the example codes and removed the logic and left only 2 lines of log to test it. Below is the code
any idea why I'm getting this error? any help will be appreciated
Summary
The user was getting an "Unexpected token 'export'" error in their function. Following a suggestion, they converted it to a module by changing the entry point filename from "index.js" to "index.mjs", which solved the issue. It was mentioned that the problem may have been caused by using a different syntax, as the function defaults to common js. The user also shared their package.json and inquired about the difference between manual deployment and deploying with the Appwrite cli. It was mentioned that the issue could be related to the Node version, as Appwrite currently uses Node v16 which is now end of life. The recommended solution
Binyamin
Sep 21, 2023, 13:44
To what version of Appwrite you're deploying this function?
manazo
Rank 3: Container
Sep 21, 2023, 16:02
the latest version. 1.4.2
Binyamin
Sep 21, 2023, 16:46
How have you created the function?
What version is your Appwrite cli?
manazo
Rank 3: Container
Sep 21, 2023, 20:15
Functions tab -> create function -> manually -> uploaded the tar file -> specified entry point (index.js) -> create -> activate
i did it manually from the console cuz it was only for testing to check what info i get in the context object
Guille
Sep 21, 2023, 20:38
It think it may be a node version problem
Drake
Sep 21, 2023, 20:39
Is this function from before 1.4?
Binyamin
Sep 21, 2023, 20:52
What is that tar file includes?
It's recommend using the latest version of Appwrite cli > 4.0.0 and deploy a function using this method.
RAKU
Sep 21, 2023, 21:59
I am also facing the same issue 😦
Update: Changing the entry point filename from "index.js" to "index.mjs" solved the issue 🙂
manazo
Rank 3: Container
Sep 22, 2023, 02:58
That might be the case. appwrite currently uses Node v16 which is now end of life, according to this post
manazo
Rank 3: Container
Sep 22, 2023, 02:59
nope. i copied this code from the official doc and removed all the logic and kept only 3 logs to test it out
Drake
Sep 22, 2023, 03:00
This is the function for the deployment. I meant did you create this function before or after 1.4?
manazo
Rank 3: Container
Sep 22, 2023, 03:01
shown in the ss. node_modules doesn't have any modules actually
and about deploying with Appwrite cli, I wonder what difference it makes when we do manual deployment. I've used the manual deployment before (before 1.4) and it worked well
manazo
Rank 3: Container
Sep 22, 2023, 03:02
after 1.4
manazo
Rank 3: Container
Sep 22, 2023, 03:08
Update: Changing the entry point filename from "index.js" to "index.mjs" solved the issue 🙂
I just tried and it worked for me as well. but i wonder what the issue was in the first place
Drake
Sep 22, 2023, 03:10
What's in your package.json ?
manazo
Rank 3: Container
Sep 22, 2023, 03:10
JSON
{
"name":"trabo-server-functions",
"version":"1.0.0",
"description":"",
"main":"index.js",
"scripts":{
"test":"echo \"Error: no test specified\" && exit 1"