I tried creating a function from appwrite using npx appwrite init function , I created a file auth.js which I imported in main.js. But I get the error during execution:
TypeScript
Error [ERR_MODULE_NOT_FOUND]: Cannot find module '/usr/local/server/src/function/src/auth' imported from /usr/local/server/src/function/src/main.js
at new NodeError (node:internal/errors:372:5)
at finalizeResolution (node:internal/modules/esm/resolve:405:11)
at moduleResolve (node:internal/modules/esm/resolve:966:10)
at defaultResolve (node:internal/modules/esm/resolve:1176:11)
at ESMLoader.resolve (node:internal/modules/esm/loader:605:30)
at ESMLoader.getModuleJob (node:internal/modules/esm/loader:318:18)
at ModuleWrap.<anonymous> (node:internal/modules/esm/module_job:80:40)
at link (node:internal/modules/esm/module_job:78:36)
TL;DR
I created a function in JS using `npx appwrite init function`, which resulted in a relative import error. The error was `Error [ERR_MODULE_NOT_FOUND]: Cannot find module '/usr/local/server/src/function/src/auth' imported from /usr/local/server/src/function/src/main.js`. The solution to this issue is to include the file extension (.js) along with the import statement.We have to also include the extension along with the import statement to make it work.
The issue is solved for now
[SOLVED] Relative imports not allowed in writing functions in JS
Recommended threads
- HUGE OUTRAGE IN APPWRITE, I CANNOT ACCES...
I have 2k users trying to access, sending me messages. What am I supposed to do? Please solve this asap.
- All my apps are not opening now
All my apps are not opening now 200+ apps are not opening plz fast
- Dotnet functions on cloud
I'm trying to deploy my .Net8 functions to my project on cloud.appwrite through the CLI. I'm getting this error.