Skip to content

Error: the promise constructor cannot be invoked directly

glmdgrielson edited this page Oct 15, 2017 · 3 revisions

Error: the promise constructor cannot be invoked directly.

You can get this error for several reasons:

1. You forgot to use new when creating a new promise using new Promise(resolver) syntax.

This can happen when you tried to do something like:

return Promise(function(resolve,reject){
       //...
})

You can correct this by doing:

return new Promise(function(resolve,reject){
       //...
})

Please consider reading more about promisification and also consider checking out automatic promisification as well as Promise.method

2. You are trying to subclass Promise

Bluebird does not support extending promises this way. Instead, see the Guide for Library Authors.