any one knows a guide on how to deploy this template here https://github.com/appwrite/templates/tree/main/node/storage-cleaner
to appwrite function manually? i pull the code, tar.gzip the src folder, and used 1.4.9's function to select upload manually and when i execute the function, i got this error
Could not load code file. Error: Cannot find module '/usr/local/server/src/function/index.js' Require stack: /usr/local/server/src/server.js at Function.Module._resolveFilename (node:internal/modules/cjs/loader:940:15) at Module.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:93:18) at execute (/usr/local/server/src/server.js:123:28) at /usr/local/server/src/server.js:158:33 at processTicksAndRejections (node:internal/process/task_queues:96:5)
Did you make sure to include npm install as part of the build command?
if i add that for build command, another error comes out
/usr/local/server/src/function/main.js:1 import AppwriteService from './appwrite.js'; ^^^^^^
SyntaxError: Cannot use import statement outside a module at Object.compileFunction (node:vm:355:18) at wrapSafe (node:internal/modules/cjs/loader:1038:15) at Module._compile (node:internal/modules/cjs/loader:1072:27) at Object.Module._extensions..js (node:internal/modules/cjs/loader:1137:10) at Module.load (node:internal/modules/cjs/loader:988:32) at Function.Module._load (node:internal/modules/cjs/loader:828:14) at Module.require (node:internal/modules/cjs/loader:1012:19) at Module.Hook._require.Module.require (/usr/local/lib/node_modules/pm2/node_modules/require-in-the-middle/index.js:101:39) at require (node:internal/modules/cjs/helpers:93:18) at execute (/usr/local/server/src/server.js:123:28)
thanks for you reply @Steven , i'm quite new to 1.4 , everything's so much awesome that i felt lost
Please make sure to format multi line stuff like this with backticks like you would in markdown
Wait is the function created after upgrading to 1.4?
yes, its the function i try to create using template available on github basically there was another script i use for 1.3, but since i upgraded to 1.4, i found that the script no longer compatible for 1.4, i ask around and someone here pointed to use https://github.com/appwrite/templates/tree/main/node/storage-cleaner what i did just pull the template script, and tar.gz it then create a new deployment on my 1.4 appwrite
Your function from before 1.4 will continue to work with the old syntax.
To use the new one, you'll need to create a new function
yes, got that, im creating a new function to clear storage from another project that did not have function yet
but unable to do it successfully so far
so what's the error in the new function?
if i create tar.gzip from entire folder of "storage-cleaner", upload it manually(nodejs runtime) as new function, then execute it with "npm install" as build command, i will get this error 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 Function.Module._resolveFilename (node:internal/modules/cjs/loader:940:15) at Module.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:93:18) at execute (/usr/local/server/src/server.js:123:28) at /usr/local/server/src/server.js:158:33 at processTicksAndRejections (node:internal/process/task_queues:96:5)
i did not touch anything for the folder structure of "storage-cleaner"
my "create deployment" screen
my execute screen
the error
are you crating an archive of the contents of the folder or the folder itself?
the folder itself
just tried it with the content of the folder , same error Could not load code file. Error: Cannot find module '/usr/local/server/src/function/main.js' Require stack:
- /usr/local/server/src/server.js
@Steven any idea?
Still probably a problem with the folder structure.
How about to initialize a function using the Appwrite CLI and execute that starter function?
i tried it this morning, and its not folder structure, its "entrypoint" , as the file is in "storage-cleaner/src", i need to add "src/main.js" in the entrypoint when uploading it manually
Recommended threads
- I'm getting an error on the console "j?....
On my self hosted instance version 1.8.1 the console is giving me this error when trying to view the rows for a table I recently created. My application is read...
- local build `composer installer:dev` iss...
setup - dev container (default linux universal) WSL (test with gh codespace too) - php 8.5.7 - all extensions installed - `composer install` fine - `composer...
- Function global variables
when i create a top-level global variable in go or bun how will it behave? is the heap getting renewed on every execution or could i do some kind of temp. cachi...