Jeremy
Jeremy

Reputation: 1835

node require bluebird failing

I am running a node.js app and for some reason the node app is failing when requiring the bluebird module require('bluebird').

This is really strange and the only thing I have to go off of is the stack trace here:

TypeError: Cannot call method 'split' of undefined  
    at Object.setBounds (app/node_modules/bluebird/js/release/debuggability.js:614:48)  
    at module.exports (app/node_modules/bluebird/js/release/promise.js:762:11)  
    at Object.<anonymous> (app/node_modules/bluebird/js/release/bluebird.js:9:36)  
    at Module._compile (module.js:456:26)  
    at Object.Module._extensions..js (module.js:474:10)
    at Module.load (module.js:356:32)
    var firstStackLines = firstLineError.stack.split("\n");

Again, the app runs just fine. When I add this one line require('bluebird') it crashes and I get this stack trace. Any ideas on what this error is coming from?

[Edit]

at line node_modules/bluebird/js/release/debuggability.js:614:48

> console.log(firstLineError);
[Error]
> console.log(firstLineError.message);

> console.log(firstLineError.stack);
undefined
> console.log(firstLineError.toString());
Error: Error
> console.log(firstLineError instanceof Error);
True

It is an Error object that is essentially empty

temporary solution

When I change the line node_modules/bluebird/js/release/debuggability.js:614 to

var firstStackLines = (firstLineError.stack) ? firstLineError.stack.split("\n") : ""; 

and line 615 to

var lastStackLines = (lastLineError.stack) ? lastLineError.stack.split("\n") : "";

it works just fine. Not sure if this has lasting effects though

Upvotes: 3

Views: 929

Answers (4)

hammus
hammus

Reputation: 2612

The problem for me was that I was using another module pretty-error that was modifying the console object and therefore, bluebirds error handling was receiving a mutated console object that was not the shape that bluebird expected.

Upvotes: 0

nyanstarfish
nyanstarfish

Reputation: 31

I had the similar failures, more specifically:

.../node_modules/bluebird/js/release/debuggability.js:673
var firstStackLines = firstLineError.stack.split("\n");

when using node 6.2.2 with bluebird^3.4.1.

Upgrading to bluebird^3.4.6 with node v6.2.2 helped fix the error.

Upvotes: 1

Amin Shah Gilani
Amin Shah Gilani

Reputation: 9826

You're using the latest version of Bluebird with an outdated version of node.

Upvotes: 0

Kyros
Kyros

Reputation: 512

Manually remove your node_modules folder and re-run npm install as it sounds like NPM didn't correctly install something.

Upvotes: 0

Related Questions