Function execution error : Cannot find module '/usr/local/server/src/function/main.js'
- 1
- Functions

I just deployed appwrite function to my selfhost appwrite connected github also build the function succesfully but I get this error when I try to execute the function for get request inside the appwrite dashboard
`Could not load code file. Error: Cannot find module '/usr/local/server/src/function/main.js' Require stack:
- /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 execute (/usr/local/server/src/server.js:123:28) at /usr/local/server/src/server.js:158:33 at process.processTicksAndRejections (node:internal/process/task_queues:95:5)`

I created the function locally with appwrite cli and didn't change anyting from the generated code just push it to my repo

This is the function code inside main.js
`import { Client } from 'node-appwrite';
// This is your Appwrite function
// It's executed each time we get a request
export default async ({ req, res, log, error }) => {
// Why not try the Appwrite SDK?
//
// const client = new Client()
// .setEndpoint('https://cloud.appwrite.io/v1')
// .setProject(({}).APPWRITE_FUNCTION_PROJECT_ID)
// .setKey(({}).APPWRITE_API_KEY);
// You can log messages to the console
log('Hello, Logs!');
// If something goes wrong, log an error
error('Hello, Errors!');
// The `req` object contains the request data
if (req.method === 'GET') {
// Send a response with the res object helpers
// `res.send()` dispatches a string back to the client
return res.send('Hello, World!');
}
// `res.json()` is a handy helper for sending JSON
return res.json({
motto: 'Build Fast. Scale Big. All in One Place.',
learn: 'https://appwrite.io/docs',
connect: 'https://appwrite.io/discord',
getInspired: 'https://builtwith.appwrite.io',
});
};

What's your repo and build settings for the function?
Fyi, it's best to use 3 backticks for multi line code
Recommended threads
- Unable to add permission when creating a...
I am creating a collection from a cloud function using the Appwrite Dart server SDK, and I want to add permissions so it can be accessed by users. I added code ...
- Create owner team member with Server fun...
I understand that when creating a team with a function, the user that made the request will not be the owner so I think I have to add the user that did the requ...
- Schedule a function job with timezone
I am aware that cron schedule will work on UTC timezone. I would like to run my function at a particular time everyday in new york time. If I use UTC, it will m...
