Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I make require() use node_modules in Parse Cloud Code?

I can happily upload npm module source, but if I try to require('foo') then it ignores the node_modules directory, unless I exactly specify require('./node_modules/foo/index.js').

How can I work around this to use npm modules on parse?

like image 307
Paul Tarjan Avatar asked May 15 '26 06:05

Paul Tarjan


2 Answers

Parse does not support npm now. You have to locate it manually. There are still problem about it. Suppose I added 'cheerio' like this require('cloud/cheerio'), so parse will get the cheerio module. But cheerio has some dependencies. So inside the cheerio source code you will see there are lots of require('.........'), if you want to use cheerio you have edit them require('cloud/cheerio/lib/path/etc.........'), which is a very bad solution. Even parse cloud do not lets you upload json file. Cheerio use few json files for him.

So for now you can't add npm with parse. It's a MAJOR fault of parse in this world of javascript.

like image 167
Imdadul Huq Naim Avatar answered May 17 '26 06:05

Imdadul Huq Naim


Until Parse supports npm, I'm using http://browserify.org/ to bundle all my code into a single cloud.js file and then uploading that.

like image 32
Paul Tarjan Avatar answered May 17 '26 06:05

Paul Tarjan



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!