I deployed new appwrite function in the appwrite cloud, and on execution this is what I get.
Could not load code file.
Error: Cannot find module 'node-appwrite'
Require stack:
- /usr/local/server/src/function/src/index.js
- /usr/local/server/src/server.js
at Module._resolveFilename (node:internal/modules/cjs/loader:939:15)
at 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:102:18)
at Object.<anonymous> (/usr/local/server/src/function/src/index.js:3:25)
at Module._compile (node:internal/modules/cjs/loader:1105:14)
at Module._extensions..js (node:internal/modules/cjs/loader:1159:10)
at Module.load (node:internal/modules/cjs/loader:981:32)
at Module._load (node:internal/modules/cjs/loader:827:12)
at Module.require (node:internal/modules/cjs/loader:1005:19)
at Hook._require.Module.require (/usr/local/lib/node_modules/pm2/node_modules/require-in-the-middle/index.js:101:39)
@Matej Is this a newly deployed function?
Or do you have deployed an update to the corresponding existing function?
Newly deployed
from CLI
Are you using new function formatting?
What's new formating?
I am using what CLI gave me
Update cli to latest version
And create a new function with CLI so you will get the new format template
π
What's the latest cli version and how do I update'
nvm I updated
Was about to send π
But, I kind of use new formating in my firstly deployed function anyway π€
I'll try to deploy new one and see if it changes anything
ReferenceError: exports is not defined in ES module scope This file is being treated as an ES module because it has a '.js' file extension and '/usr/local/server/src/function/package.json' contains "type": "module". To treat it as a CommonJS script, rename it to use the '.cjs' file extension. at file:///usr/local/server/src/function/src/main.js:2:23 at ModuleJob.run (node:internal/modules/esm/module_job:198:25) at async Promise.all (index 0) at async ESMLoader.import (node:internal/modules/esm/loader:409:24) at async importModuleDynamicallyWrapper (node:internal/vm/module:437:15) at async execute (/usr/local/server/src/server.js:126:32) at async /usr/local/server/src/server.js:158:13
Ok this is now probably typescript issue
this is my tsconfig
{ "compilerOptions": { "target": "ES2022", "module": "CommonJS", "outDir": "./src", "rootDir": "./dev", "strict": true, "moduleResolution": "node", "esModuleInterop": true }, "include": [ "dev/**/*", ], "exclude": ["node_modules"] }
SyntaxError: Unexpected token u in JSON at position 0 at JSON.parse (<anonymous>) at Module.default (file:///usr/local/server/src/function/src/main.js:20:26) at execute (/usr/local/server/src/server.js:141:48) at async /usr/local/server/src/server.js:158:13
Making progress. π
@D5 Ok and I was also doing req.payload instead req.body
Along with few hickups here and there, thing are now working.
Also updated tsconfig.json module to ES2022
Can close this, ty π
Perfect. Sorry for not replying faster
[SOLVED] Appwrite function can't find node-appwrite module
Recommended threads
- The file size is either not valid or exc...
Hello, I am receiving the following error when I am trying to deploy a function from my local. ``` > appwrite push functions --function-id xxxxxxxxx βΉ Info: Va...
- How does sending email from the Appwrite...
I noticed that the pricing page mentions βMessages β 1000 per monthβ for the Free plan. Is this different from sending emails? When I try to send an email usin...
- Appwrite functions dart runtime (3.7 sup...
It seems that currently Appwrite functions only support Dart runtime to 3.5, for my code I need dart 3.7. Is there any plan to support Dart3.7 runtime soon. Is ...