How to enable PouchDB Debug in Angular

1k views Asked by At

I am developing a prototype web application. I used Yeoman to create an Angular application with Grunt, NPM, and Bower etc. The PouchDB API says you can enable debugging like so:

PouchDB.debug.enable('*');

This however requires the node debug module to be installed. I have tried installing it via bower and referencing it in my index.html but to no avail. How do I inject the debug module into Angular? Or is this function only available when the PouchDB is ran from a Node.js server?

EDIT:

The exact error I am getting is bellow. The line it complains about is: PouchDB.debug.enable('*');

TypeError: Cannot read property 'enable' of undefined
    at new <anonymous> (http://localhost:9000/scripts/services/taskdb.js:13:15)
    at invoke (http://localhost:9000/bower_components/angular/angular.js:4129:17)
    at Object.instantiate (http://localhost:9000/bower_components/angular/angular.js:4140:23)
    at Object.<anonymous> (http://localhost:9000/bower_components/angular/angular.js:3998:24)
    at Object.invoke (http://localhost:9000/bower_components/angular/angular.js:4129:17)
    at Object.enforcedReturnValue [as $get] (http://localhost:9000/bower_components/angular/angular.js:3982:37)
    at Object.invoke (http://localhost:9000/bower_components/angular/angular.js:4129:17)
    at http://localhost:9000/bower_components/angular/angular.js:3947:37
    at getService (http://localhost:9000/bower_components/angular/angular.js:4088:39)
    at Object.invoke (http://localhost:9000/bower_components/angular/angular.js:4120:13)
angular.js:11413 TypeError: Cannot read property 'enable' of undefined
    at new <anonymous> (http://localhost:9000/scripts/services/taskdb.js:13:15)
    at invoke (http://localhost:9000/bower_components/angular/angular.js:4129:17)
    at Object.instantiate (http://localhost:9000/bower_components/angular/angular.js:4140:23)
    at Object.<anonymous> (http://localhost:9000/bower_components/angular/angular.js:3998:24)
    at Object.invoke (http://localhost:9000/bower_components/angular/angular.js:4129:17)
    at Object.enforcedReturnValue [as $get] (http://localhost:9000/bower_components/angular/angular.js:3982:37)
    at Object.invoke (http://localhost:9000/bower_components/angular/angular.js:4129:17)
    at http://localhost:9000/bower_components/angular/angular.js:3947:37
    at getService (http://localhost:9000/bower_components/angular/angular.js:4088:39)
    at invoke (http://localhost:9000/bower_components/angular/angular.js:4120:13) <div ng-view="" class="ng-scope">
2

There are 2 answers

2
nlawson On BEST ANSWER

When you use PouchDB, the debug module is already installed. You don't need to do anything except call PouchDB.debug.enable('*'). :)

0
jacobq On

Note that in PouchDB v7.0.0 loading a separate plugin is required for this.