How to enable PouchDB Debug in Angular - javascript

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">

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

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

Related

Angular Fullstack is not working for Yomen

events.js:160
throw er; // Unhandled 'error' event
^
Error: Cannot find module 'generator-ng-component/generators/route'
at Function.Module._resolveFilename (module.js:470:15)
at Function.resolve (internal/module.js:27:19)
at child.compose (/usr/local/lib/node_modules/generator-angular-fullstack/generators/route/index.js:7:92)
at Object.<anonymous> (/usr/local/lib/node_modules/generator-angular-fullstack/node_modules/yeoman-generator/lib/base.js:439:23)
at /usr/local/lib/node_modules/generator-angular-fullstack/node_modules/yeoman-generator/node_modules/run-async/index.js:25:25
at /usr/local/lib/node_modules/generator-angular-fullstack/node_modules/yeoman-generator/node_modules/run-async/index.js:24:19
at /usr/local/lib/node_modules/generator-angular-fullstack/node_modules/yeoman-generator/lib/base.js:440:9
at runCallback (timers.js:649:20)
at tryOnImmediate (timers.js:622:5)
at processImmediate [as _immediateCallback] (timers.js:594:5)
It is my guess that it's an issue with the angular-fullstack generators.
I have been encountering the same issue when performing the following command:
yo angular-fullstack:route [myroute]
angular-fullstack generators are now integrating Angular2, but may not be fully finished. For example, endpoints are working
yo angular-fullstack:enpoint [myendpoint]
I assume this because the code for generator-angular-fullstack/generators/endpoint or generator-angular-fullstack/generators/component look very different than generator-angular-fullstack/generators/route.
Unfortunately, this isn't a solution. If I am correct, I guess we can either wait for an update or create new routes manually for now.
EDIT: generator-angular-fullstack#5.0.0-alpha.3.

gulp-uglify not working

Here is my repository
https://github.com/shellwe/QA_WP_Template
If you just needed to see the code snippet; here it is
gulp.task('uglify', function() {
return gulp.src('js/all.min.js')
.pipe(uglify())
.pipe(gulp.dest('js/'));
});
I am running "gulp uglify" and I am getting the following errors.
events.js:160
throw er; // Unhandled 'error' event
^
Error
at new JS_Parse_Error (eval at <anonymous> (C:\Users\sh3240\Documents\My Web Sites\wordpress\wp-content\themes\QA_WP_Template\node_modules\uglify-js\tools\node.js:28:1), <anonymous>:1534:18)
at js_error (eval at <anonymous> (C:\Users\sh3240\Documents\My Web Sites\wordpress\wp-content\themes\QA_WP_Template\node_modules\uglify-js\tools\node.js:28:1), <anonymous>:1542:11)
at croak (eval at <anonymous> (C:\Users\sh3240\Documents\My Web Sites\wordpress\wp-content\themes\QA_WP_Template\node_modules\uglify-js\tools\node.js:28:1), <anonymous>:2089:9)
at token_error (eval at <anonymous> (C:\Users\sh3240\Documents\My Web Sites\wordpress\wp-content\themes\QA_WP_Template\node_modules\uglify-js\tools\node.js:28:1), <anonymous>:2097:9)
at unexpected (eval at <anonymous> (C:\Users\sh3240\Documents\My Web Sites\wordpress\wp-content\themes\QA_WP_Template\node_modules\uglify-js\tools\node.js:28:1), <anonymous>:2103:9)
at semicolon (eval at <anonymous> (C:\Users\sh3240\Documents\My Web Sites\wordpress\wp-content\themes\QA_WP_Template\node_modules\uglify-js\tools\node.js:28:1), <anonymous>:2123:56)
at simple_statement (eval at <anonymous> (C:\Users\sh3240\Documents\My Web Sites\wordpress\wp-content\themes\QA_WP_Template\node_modules\uglify-js\tools\node.js:28:1), <anonymous>:2314:73)
at eval (eval at <anonymous> (C:\Users\sh3240\Documents\My Web Sites\wordpress\wp-content\themes\QA_WP_Template\node_modules\uglify-js\tools\node.js:28:1), <anonymous>:2183:19)
at eval (eval at <anonymous> (C:\Users\sh3240\Documents\My Web Sites\wordpress\wp-content\themes\QA_WP_Template\node_modules\uglify-js\tools\node.js:28:1), <anonymous>:2136:24)
at eval (eval at <anonymous> (C:\Users\sh3240\Documents\My Web Sites\wordpress\wp-content\themes\QA_WP_Template\node_modules\uglify-js\tools\node.js:28:1), <anonymous>:2904:23)
Most examples I see had concat and uglify in one process but since the concat part was working I broke them apart to show that. I know its something wrong with uglify, I just can't figure out what I am doing wrong.
The error you are getting doesn't really explain much... However, according to the little "documentation" on npm.js of gulp-uglify,
To help properly handle error conditions with Node stream, this project recommends the use of pump
You can read up on gulp-uglify and pump.
So, I tried the following:
# grab pump
npm install pump --save-dev
Then, in the gulpfile.js, I did the following:
gulp.task('uglify2', function (cb) {
pump([
gulp.src('./js/all.min.js'),
uglify(),
gulp.dest('./js/')
],
cb
);
});
The error that I am getting, which by the way, is a lot nicer than the error you are getting, is the following:
The problem seems to be on line 191, which suggests that there is something wrong with your code, rather than your gulp task.

AngularJS + Webpack Mysterious Bug - Cannot read property 'call' of undefined

I'm working on a project using AngularJS with Webpack, I'm getting a very weird bug:
Sometimes an error will show up:
TypeError: Cannot read property 'call' of undefined
at __webpack_require__ (vendor.js:51)
at Object.357 (templates.js:377)
at __webpack_require__ (vendor.js:51)
at exam (app.js:17755)
at Object.invoke (vendor.js:21978)
at vendor.js:24895
at forEach (vendor.js:17592)
at Object.<anonymous> (vendor.js:24893)
at Object.invoke (vendor.js:21978)
at Object.enforcedReturnValue [as $get] (vendor.js:21817)(anonymous function) # vendor.js:30912
The weird part: When i comment out the recently changed piece of code, and re-insert it (such that the code is the same), it suddenly works for a little while, then the same error appears !
I don't have the slightest clue as to what's causing this, Any help will be greatly appreciated.

Cannot use Bower because of node.js error

I'm trying to use bower to install everything for the website I am working on, but every time I try to use it, I get the error:
TypeError: Object #<Object> has no method 'toLowerCase'
at Function.Buffer.isEncoding (buffer.js:240:32)
at assertEncoding (evalmachine.<anonymous>:98:27)
at Object.fs.writeFileSync (evalmachine.<anonymous>:908:3)
at Object.create.all.set (/usr/local/lib/node_modules/bower/node_modules/configstore/index.js:64:8)
at Object.Configstore (/usr/local/lib/node_modules/bower/node_modules/configstore/index.js:27:11)
at readCachedConfig (/usr/local/lib/node_modules/bower/lib/config.js:19:23)
at defaultConfig (/usr/local/lib/node_modules/bower/lib/config.js:11:12)
at Object.<anonymous> (/usr/local/lib/node_modules/bower/lib/index.js:40:32)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
I have been searching for a while on the internet but cannot manage to find the solution for this problem.
I am trying to run it on Linux Mint 17.2
Problem solved by downloading the Node.js sources and by recompiling it.

Node.js Box2dWeb error caused by require()

I'm trying to make a server using Node.js and Box2dWeb engine. But trying to "import" the "box2d.js" throws me a random error which doesn't seem to be related with what I'm doing. Here's the code that's causing the error:
var Box2D = require('./box2d.js');
Here's the error:
console.js:55
this._stdout.write(util.format.apply(this, arguments) + '\n');
^
TypeError: Cannot read property 'write' of undefined
at Console.log (console.js:55:15)
at TCPServer.<anonymous> (C:\Users\conne_000\Documents\ntm2\NTM2Server2\main
.js:16:10)
at TCPServer.emit (events.js:129:20)
at Server.<anonymous> (C:\Users\conne_000\Documents\ntm2\NTM2Server2\classes\servers\tcp_server.js:20:8)
at Server.emit (events.js:104:17)
at net.js:1171:12
at process._tickCallback (node.js:355:11)
at Function.Module.runMain (module.js:503:11)
at startup (node.js:129:16)
at node.js:814:3
Press any key to continue . . .
I have no idea on what to do about this. Any help is very much appreciated!

Categories