SyntaxError: Cannot use import statement outside a module <Cloud Functions>
- 0
- Functions
- Web
- Cloud

/usr/local/server/src/function/src/main.ts:1 import { Client, Users, Databases } from 'node-appwrite
i tried to switch from js
to ts
in cloud functions, i've changed the main.js
to main.ts
and also changed the package.json
{
"name": "starter-template",
"version": "1.0.0",
"description": "",
"main": "src/main.ts",
"type": "module",
"scripts": {
"format": "prettier --write ."
},
"dependencies": {
"node-appwrite": "^9.0.0"
},
"devDependencies": {
"prettier": "^3.0.0"
}
}
and also updated the Entrypoint
in the function Configuration
section src/main.ts
but still didn't want to wrok

You won't be able to use typescript
like so out of the box in Node fucntion
For this to work change index to js
then copy this to your json
file
{
"name": "starter-template",
"version": "1.0.0",
"description": "",
"main": "src/main.js",
"type": "module",
"scripts": {
"format": "prettier --write ."
},
"dependencies": {
"node-appwrite": "^11.1.1"
},
"devDependencies": {
"prettier": "^3.0.0"
}
}

If you do want to use typescript
I'll suggest creating bun
function

Check the bun starter code

thank you, will check that! so there is no wy to use typescript in nodejs ?

Not right now, no

But bun
offers almost the same features
Recommended threads
- Why "You’ve reached the limit for your G...
Why did Appwrite send me this alert when the usage reached 10605%? Is it too late? Why not when reached 100% usage? And I can not pay for more usage described ...
- Subdomain failed verification
So I wanted to do a custom subdomain, because local storage doesn't work for me, but I've tried it a long time ago, it didn't work for me, and now I'm trying ag...
- Sites 30MB limit from GitHub
I’m deploying a site from github as Other type on the Hobby plan. It is actually a Flutter web app but it’s in a subdirectory with the root being an html landin...
