Back

[SOLVED] Cannot delete user account with functions

  • 0
  • Web
NZX
8 Dec, 2023, 19:04

Hello, I've set up a Function to delete user account completely from database.

This is my set up:

On delete account button press:

TypeScript
 const response = await fetch("/api/deleteUser", {
        method: "POST",
        headers: {
          "Content-Type": "application/json",
        },
        body: JSON.stringify({ userId: user.$id }),
      });

Which goes to api/deleteUser: (picture 1)

Then the function set up with root entry functions/deleteUserFunction/index.js (picture 2)

The entrypoint set up (picture 3)

The error i get in Function logs:

Could not load code file. Error: Cannot find module 'node-appwrite' Require stack:

  • /usr/local/server/src/function/functions/deleteUserFunction/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/functions/deleteUserFunction/index.js:1:29) 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)

Thanks for help !

TL;DR
User is experiencing an error when trying to delete a user account using a function. The error message suggests that a module 'node-appwrite' cannot be found. The user has already set up the function and checked their package.json file. They have tried redeploying and retesting the function on their website, but the error persists. Solution: Fix the build environment by ensuring that the package.json file is at the root of the function tar.gz file.
NZX
8 Dec, 2023, 19:06

And this in my package.json in functions/deleteUserFunction, it said need appwrite will install it automatically but is not working

AidsMcGhee
8 Dec, 2023, 19:11
AidsMcGhee
8 Dec, 2023, 19:11

Dont rely on appwrite to do anything automatically from what i've learned

NZX
8 Dec, 2023, 19:12

lmao

NZX
8 Dec, 2023, 19:12

ok i wil try that

AidsMcGhee
8 Dec, 2023, 19:12

redeploy when u change it

AidsMcGhee
8 Dec, 2023, 19:12

your entrypoint is index.js

NZX
8 Dec, 2023, 19:13

i write just index.js as entrypoint?

AidsMcGhee
8 Dec, 2023, 19:13

since you got this error /usr/local/server/src/function/functions/deleteUserFunction/index.js

AidsMcGhee
8 Dec, 2023, 19:14

your entrypoint was/is correct. just dont copy my screenshot for entrypoint

NZX
8 Dec, 2023, 19:14

aah ok

NZX
8 Dec, 2023, 19:15

@AidsMcGhee Now wth is this 🤣

AidsMcGhee
8 Dec, 2023, 19:15

yeah.. run it again. ive created an issue ffor this and theyve yet to fix it. surprise lol

NZX
8 Dec, 2023, 19:18

now back to this 🤡 🤡

AidsMcGhee
8 Dec, 2023, 19:19

did you hit the redeploy button?

NZX
8 Dec, 2023, 19:20

yes , now i re builded it. It does the multiple internal curl

NZX
8 Dec, 2023, 19:20

So now I re test my fucntion on my website or i redploy?

NZX
8 Dec, 2023, 19:20

Re testing on my website made the cannot find module before again

AidsMcGhee
8 Dec, 2023, 19:20

execute it again once u get the multiple curl error

NZX
8 Dec, 2023, 19:23

back to cannot find

NZX
8 Dec, 2023, 19:23

AAAAAAAAAA

NZX
8 Dec, 2023, 19:23

why they remove delete account from client 🤡

AidsMcGhee
8 Dec, 2023, 19:24

you might need to fix your build env. when i build my typescript, it outputs a main.js and package.json file with no extra folders

AidsMcGhee
8 Dec, 2023, 19:24

if package.json is not at the root of the function tar.gz the npm install won't do anything

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