Hey @matiyin
Regarding the watch-cloud-folder
command:
/bin/sh: 1: ncc: not found
This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). The promise rejected with the reason:
Error: Command failed: ncc build ./output.js -o dist
/bin/sh: 1: ncc: not found
This is a known issue that we are fixing in the next release.
You can work around it by running the command npm i -g @vercel/ncc
(use sudo
if you are on Mac os Linux or open the cmd as administrator if you are on Windows).
Also the path is not correct as it should point to a folder not to a JS file.
An example:
1 - I have created an empty folder in my desktop called test-cloud-folder
;
2 - I run the script watch-cloud-folder
, let’s analyse the command:
moralis-admin-cli watch-cloud-folder --moralisApiKey NF0zYKHE639fANS --moralisApiSecret 4wV32YycpAos93j --moralisCloudfolder /Users/dani/Desktop/test_cloud_folder --moralisSubdomain vc3clw6eam3t.moralis.io --autoSave 1
Notice how the --moralisCloudfolder
points to a folder /Users/dani/Desktop/test_cloud_folder
.
The param --autoSave
is set to 1 (true) which means that every time you will save a .JS file inside the folder specified, it will be pushed to cloud.
If I run the command above I get the same error as you:
Run npm i -g @vercel/ncc
:
You are ready to go!
Run again moralis-admin-cli watch-cloud-folder --moralisApiKey NF0zYKHE639fANS --moralisApiSecret 4wV32YycpAos93j --moralisCloudfolder /Users/dani/Desktop/test_cloud_folder --moralisSubdomain vc3clw6eam3t.moralis.io --autoSave 1
and have fun, create a .js file in the folder you are pointing, write a cloud function in that file and save it, it will be uploaded to cloud automatically as soon as you save it!
Do not worry about all the other code that you see around you function, this is there to help you coding amazing stuff.
Why did we choose to add this watch-cloud-file
script?
Because you can now split your cloud code in multiple folders and you can use node_modules.
We have some npm modules whitelisted that you can use in your cloud function.
Try the script out and keep us posted.
Happy coding,
Dani