Cannot find module 'underscore.js'

507 views
Skip to first unread message

Ricardo Lage

unread,
Sep 25, 2016, 1:28:48 PM9/25/16
to back{4}app
Hi,

I'm having trouble setting the Cloud Code. Getting a "invalid function" error message.

The log is saying that "underscore" is not loaded:

Cloud Code not loaded:
 { [Error: Cannot find module 'underscore.js'] code: 'MODULE_NOT_FOUND' }


Is it possible to install it? How should I proceed.

Thank you very much,
Ricardo

Davi Macêdo

unread,
Sep 25, 2016, 6:52:13 PM9/25/16
to back{4}app
Hi, Ricardo.

It is already installed for all apps.

Probably you are doing require('./underscore'). Try require('underscore'), instead.

Best!

Ricardo Lage

unread,
Sep 26, 2016, 1:48:50 AM9/26/16
to back{4}app
Thanks, I had to replace require('underscore.js'); wirh require('underscore');

But now I'm having the following problem:

Cloud Code not loaded:
 [Error: Most middleware (like bodyParser) is no longer bundled with Express and must be installed separately. Please see https://github.com/senchalabs/connect#middleware.]
The server is listening on port 3000

In my code I use:

app.use(express.bodyParser()); // Middleware for reading request body

Is it possible to install it too?

Thank you,
Ricardo

Davi Macêdo

unread,
Sep 26, 2016, 9:59:50 AM9/26/16
to back{4}app
Hi, Ricardo. Can you please send me your app id to ad...@back4app.com?

Best.

Prasanjit Biswas

unread,
Mar 25, 2017, 1:11:04 AM3/25/17
to back{4}app
I'm trying to use  _.groupBy function of underscore in cloud code. But it fails without error. do we need to manually add underscore.js?

casag...@back4app.com

unread,
Mar 27, 2017, 7:06:42 AM3/27/17
to back{4}app
Hello!

We do have underscore.js installed for everyone. Can you show me how are you using the function, please? Also were you able to see anything on the logs? Maybe by spreading some console.log() in your code you'll be able to see when it stops running.

Best!
Reply all
Reply to author
Forward
0 new messages