-
Notifications
You must be signed in to change notification settings - Fork 4.4k
🐛 Bug Report: Cloud Functions: cannot use import statement outside a module #6104
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Does it work if you use below format? const {Client} = require('node-appwrite'); |
@ItzNotABug Thanks, this solves the error. I'm guessing though that it should work with ESM syntax as well, because the docs use ESM syntax. But now I have another error:
It doesn't pass |
that is because doc refers latest appwrite 1.4 but appwrite cloud is running on 1.1.2. That me be the issue. |
I believe your project must be a See: Check this: https://github.com/appwrite/templates/tree/main/node/starter |
@ItzNotABug I tried setting
While running this code:
@tripathi-g Thanks, Is there any place where I can see the docs for 1.1.2 ? |
@stnguyen90 Thanks, that's helpful! How soon is Cloud going to be updated? |
@JorensM This isn't an Appwrite bug. Please update your package.json to be a module: {
// ...
"type": "module",
// ...
} |
@gewenyu99 thanks, I figured that out. But see #6104 (comment) |
Yes the documentation you're reading is for 1.4, not < 1.3 😅 The guide docs are always latest version. Legacy docs, refer to references and select 1.3 or your version in the top right. |
@gewenyu99 I meant the first part of this comment: #6104 (comment) I changed |
@JorensM , please use this for reference: https://github.com/appwrite/functions-starter/blob/main/node-18.0/src/index.js |
For me, I'm using Remix.run, and I had this error. On Remix, by their documentation:
So in other words, to use it properly, I needed to create a new file |
Closing this since there's no further activity and this is a caveat with Node.js imports. |
👟 Reproduction steps
👍 Expected behavior
It should execute the function without errors
👎 Actual Behavior
The logs of the function execution in the console show this:
Also if I remove the import statement, it gives me "unexpected token 'export' "
This is the code of my function:
🎲 Appwrite version
Appwrite Cloud
💻 Operating system
Windows
🧱 Your Environment
I'm using Appwrite Cloud.
👀 Have you spent some time to check if this issue has been raised before?
🏢 Have you read the Code of Conduct?
The text was updated successfully, but these errors were encountered: