Paul Tarjan
Paul Tarjan

Reputation: 50662

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?

Upvotes: 3

Views: 707

Answers (2)

Paul Tarjan
Paul Tarjan

Reputation: 50662

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.

Upvotes: 1

Imdadul Huq Naim
Imdadul Huq Naim

Reputation: 364

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.

Upvotes: 1

Related Questions