How to add your own cloud code to parse server?
I have followed instruction here http://blog.parse.com/learn/parse-server-video-series-april-2016/
And installed the parse sever locally, I ran the parse server and it worked fine.
Next, I added my cloud code directory, it replaced my main.js file. Now when I run the server (npm start) it I get this error
npm start
> [email protected] start /Users/r/parse-backend
> node index.js
module.js:341
throw err;
^
Error: Cannot find module '/cloud/playCountUpdate.js'
at Function.Module._resolveFilename (module.js:339:15)
at Function.Module._load (module.js:290:25)
at Module.require (module.js:367:17)
at require (internal/module.js:20:19)
at Object.<anonymous> (/Users/r/parse-backend/cloud/main.js:6:1)
at Module._compile (module.js:413:34)
at Object.Module._extensions..js (module.js:422:10)
at Module.load (module.js:357:32)
at Function.Module._load (module.js:314:12)
at Module.require (module.js:367:17)
npm ERR! Darwin 14.5.0
npm ERR! argv "/usr/local/Cellar/node/5.11.0/bin/node" "/usr/local/bin/npm" "start"
npm ERR! node v5.11.0
npm ERR! npm v3.8.6
npm ERR! code ELIFECYCLE
npm ERR! [email protected] start: `node index.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] start script 'node index.js'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the parse-server-example package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! node index.js
npm ERR! You can get information on how to open an issue for this project with:
npm ERR! npm bugs parse-server-example
npm ERR! Or if that isn't available, you can get their info via:
npm ERR! npm owner ls parse-server-example
npm ERR! There is likely additional logging output above.
Here is how my cloud code file looks
require('/cloud/playCountUpdate.js');
Parse.Cloud.define('hello_2', function(req, res) {
res.success('Hi');
});
The playCountUpdate.js file exsists in the cloud directory, why am I seeing this error?
Hi @candork ,
Did you manage to resolve this error?
It looks like the include path issue, checkout the index.js as example: // example: var path = require('path'); require(path.join(__dirname, '/cloud/playCountUpdate'));