w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
conditional statement not responding in js (node)
try defining func/string at the beginning of the method maybe, rather than in the if/else blocks. var func = null, string = null; // remainder of code. drop using 'var' when assigned values it's possible that string is null or doesn't have a length property in the context where you think it's failing. also, make sure you're using semicolons consistently.

Categories : Javascript

Node 'riak@192.168.1.218' not responding to pings
So the whole process here is that for some reason IP was changed on the machine riak the IP was hard-coded in /etc/riak/vm.args and /etc/riak/app.config the process to revive is the following: edit and set the new IPs in the above files sudo rm -rf /var/lib/riak/ring/* # delete the riak ring restart the machine or do the next steps: riak-admin cluster force-replace riak@127.0.0.1 riak@"hostname -i" # replace the name riak start # start the node This topic is also linked to this problem: Riak node no longer working after changing IP address

Categories : Ubuntu

Node.js and Socket.IO Not Responding in Some Servers
After talking with you on the #nodejitsu IRC channel, it seems that this may indeed be a problem with your work proxy/firewall. As was suggested to you in the chat last night, you could always try to use secure websocket connections (wss rather than ws) to see if that will allow your connections to pass through. If that doesn't work, you would need to send your connection outside of your work's connection. For instance, proxying into a computer at your home and using your home network while you're at work and want to use websockets.

Categories : Node Js

Drupal module node type creation .install vs .module
you can create node_types using both node_type_save() and hook_node_info(). Drupal Core book module creates it in hook_install. But its more common practice to do so in hook_node_info() or hook_entity_info() ( node module uses hook_entity_info() ). if you implement using hook_node_info() you are more complaint with the way drupal works. For example node_type_rebuild() will only work with values defined in hook_node_info() and not node_type_save(). Imo you should be using hook_node_info() or hook_entity_info() and let drupal core handle the rest.

Categories : Drupal

How To Require Node Module In Node REPL Without Installing Globally?
Printing undefined is normal behavior for both the browser console and the node repl. Try typing: express. (tab key) - you should get something like this: > var express = require('express'); undefined > express. express.__defineGetter__ express.__defineSetter__ express.__lookupGetter__ express.__lookupSetter__ express.constructor express.hasOwnProperty express.isPrototypeOf express.propertyIsEnumerable express.toLocaleString express.toString express.valueOf express.apply express.arguments express.bind express.call express.caller express.constructor express.length express.name express.toString

Categories : Node Js

Node.js node-apn module for Apple Push Notification stopped working after moving to Amazon EC2 instance running Ubuntu 12.04
Check your node --version s. On my Mac, homebrew installed v0.10.12 but on the server I was running v0.11.8-pre (by mistake). Apparently the present node-apn doesn't work under the unstable. I had this same extremely frustrating issue and hunted among firewalls/OpenSSH stuff until I realized the APNS connection still worked through PHP. The Ray Wenderlich script is a quick way to check if the problem is with node or elsewhere.

Categories : Node Js

Node.js http.get with Node.js step module
Here how i did it using step..... although the request module did same for image buffer download thanks to a post on stackoverflow just need to set encoding to null in request to work for buffer response. var canvas = new Canvas(3000, 3000), ctx = canvas.getContext('2d'), Image = Canvas.Image; var image_url = "http://www.a2hosting.com/images/uploads/landing_images/node.js-hosting.png"; //var image_url = 'http://upload.wikimedia.org/wikipedia/commons/1/16/AsterNovi-belgii-flower-1mb.jpg'; step( function() { request.get({ url: image_url, encoding: null }, this); }, function(err, response, body) { var img = new Image; img.src = body; ctx.drawImage(img, 0, 0, img.width, img.height);

Categories : Node Js

Manage node-postgres query
It does look, according to the documentation that pg.connect() does handle pooled connections. I would suggest however one thing you could likely do better (assuming you only have one set of credentials your app is using). If I were looking at doing this, I would work on saving duplication of effort/keystrokes/opportunities for error a bit and look at wrapping pg.connect() in some sort of function you could use that would return client. This would enable you to do something more like: app.get('/post', function(req, res) { db.run( function(client) { client.query('SELECT * FROM post', function(err, result) { res.render('post/list', { posts: result.rows }); }); }); }); However, given the way you have things done, I am not convinced you have a lot to gain by such an app

Categories : Javascript

Issue with installing Postgres on Vagrant VM using Chef: undefined method `ruby' for Config:Module
There appears to be a problem installing the "pg" gem: ================================================================================ Error executing action `install` on resource 'chef_gem[pg]' ================================================================================ Gem::Installer::ExtensionBuildError ----------------------------------- ERROR: Failed to build gem native extension. /opt/vagrant_ruby/bin/ruby extconf.rb checking for pg_config... yes Using config values from /usr/bin/pg_config

Categories : Ruby

prepared statements on nodejs not working (with node-postgres)
Is incoming string bigger than c_name length? length: 116, Secondly you see code: '42501', that should be error code, that you should search for in node-postgres project documentation or sources.

Categories : Node Js

How to use this node.js module in some file
The module exports the S3Bucket constructor function. Use it to create a new object. You can then call the handle() method on this object (since it's part of the object's prototype). var S3Bucket = require('s3-amazon-aws'); var bucket = new S3Bucket(name, options); bucket.handle(ctx, next) Regarding the various arguments you need to read the documentation of the library.

Categories : Javascript

Need help to use node-soap module
I've found how to retrieve the arguments' value : instead of args.i-uiType I used args["i-uiType"] , and instead of name: args.o-poData : 'tns:GetDataResponse': {'o-poData': result} Well I hope this can help other people, because it works for me !

Categories : Web Services

How to use log.io logging module in Node.js
I have misunderstood the log.io concept.Log.io module look for changes in log files.If there any change in that file means it will send the logs to the server.Then socket.io will display the logs in the web UI.I have tried the example given in their documentation(http://logio.org/). Now im able to see my application logs in web UI.

Categories : Node Js

Getting returned value from a JS / Node Module
You cannot access the "returned" value the way you would in other languages. Http requests in node are asynchronous, and don't return their values. Instead, you pass in a call back function, or create a callback function within the scope of the same request. For example you could complete your function like this: (I removed some of the filler) module.exports = { foo: function (options, data, callback) { 'use strict'; var completeData = ''; var post_req = http.request(options, function (res) { res.setEncoding('utf8'); res.on('data', function (chunk) { console.log(chunk); completeData += chunk; return chunk; }); res.on('end', function () { callb

Categories : Javascript

What does the util module in node.js do?
It provides useful functions. More information at nodejs documentation Such as string formatting, debugging, logging, and some type comparers for JS objects such as Array or Error, which returns just 'object' and no difference when using the typeof keyword.

Categories : Node Js

node.js what is requirejs module
There is a specially named requirejs dependency called 'module' which you can use to look up additional information from the requirejs internals. This is typically used for passing additional configuration data. From the requirejs config api documentation: There is a common need to pass configuration info to a module. That configuration info is usually known as part of the application, and there needs to be a way to pass that down to a module. In RequireJS, that is done with the config option for requirejs.config(). Modules can then read that info by asking for the special dependency "module" and calling module.config(). See also Magic Modules from the wiki: This module gives you information about the module ID and location of the current module: In that section, he has an exam

Categories : Node Js

node net module is wrapper for what ?
Yes. The net module provides you with an asynchronous network wrapper. It contains methods for creating both servers and clients (called streams). You can include this module with require('net');

Categories : Node Js

Hashmap module in node.js?
I realised I do not need a module at all. Since in javascript an array with a string index is automatically considered a map with key,value instead of index,value. So I just convert my number to a string and use an ordinary vector.

Categories : Node Js

Rexport all features from one module to another - node.js
You can have two inherit from one, using Object.create() to establish a prototype chain between them: module.exports = exports = Object.create require './one.js' # ... Or, you can simply iterate over one's properties, copying their values: one = require './one.js' Object.keys(one).forEach (key) -> exports[key] = one[key] # ...

Categories : Javascript

Can't run globally installed node module
Apparently, I made a mistake to add bin path in .bashrc. It should be .bash_profile in Mac OS. After adding the /usr/local/share/npm/bin/ in $PATH, everything works fine.

Categories : Node Js

Array class as new module in Node JS
If you add to the Array prototype directly from within a module, it'll be accessible to the Array in the main scope To see this, put the following line in foo.js: Array.prototype.foo = "bar"; Then fire up the repl and run $ node > Array.prototype.foo undefined // <-- Array normally doesn't have foo > require('./foo') {} > Array.prototype.foo 'bar' // <-- note how it's defined now > [].foo 'bar' // <-- as expected You can do the same thing with other basic objects like Number

Categories : Javascript

Different syntax on mongodb module in Node.js
MongoClient is the new prefered way for all the different drivers. It has acknowledged (safe) writes on by default and should be the general interface to MongoDB. See http://blog.mongodb.org/post/36666163412/introducing-mongoclient for more information about how and why.

Categories : Node Js

Node.js won't let me install the xml2json module
Seems like an issue with some packages that use Python for build, and with Windows 7 64bit. Several Google searches reveal that the most popular things to try are: Downgrade node to v0.8.x Set your PYTHON env variable to "" (the empty string) Install Python in C:Python and the set the following env variables. PYTHONPATH=C:Python PYTHON=%PYTHONPATH%python.exe Good luck!

Categories : Node Js

Node JS override standard module
I feel obliged to strongly warn you against overriding native functions. That being said, this will work: main.js: var fs = require('fs'), oldReadFile = fs.readFile; fs.readFile = function (filename, options, callback) { console.log('hey!'); oldReadFile(filename, options, callback) }; var other = require('./other'); other.test(); other.js: var fs = require('fs'); exports.test = function () { fs.readFile('./main.js', {encoding: 'utf8'}, function (err, data) { console.log(err, data); }); }; You'll need to wrap your user's script with your own to first override what you want.

Categories : Javascript

Node.js Module Correct Usage
In your example it looks like you are exporting a single function, which looks like an express server. Since that module in your snippet doesn't export anything, there's no need for a wrapper function. Commonly you will see server.js type files that run an express server as main entrypoint programs that don't have any mention of module.exports. They just have top-level code that executes when you run node server.js, which is fine. If for some reason you want to be able to have a separate module require this module and start it with a function call, like: var server = require('./server'); server(); //call the function to start the express server Then what you have is OK, but I try to keep the portion of my source code intimately tied to the CommonJS extensions, which I believe will fall

Categories : Javascript

Error in installing node.js module using npm
You need to add VCBuild.exe to your path. Check out this answer on how to do it: Testacular install failes, no vcbuild.exe

Categories : Node Js

Use of 'resumeSession' event for node's TLS module
If I understand your question correctly, you are asking how to resume a TLS session on the client-side with tls.connect(options, [callback]). To make it short: You can't. You'd need to be able to send the session ID of the previous session. This is currently not implemented in Node's API. To be a bit more sophisticated: You could. Maybe you'd like to open an issue.

Categories : Javascript

node cannot find express module?
npm express -v doesn't show the version of Express that you have installed, it shows the version of npm. To show which version of Express you have installed, try this: npm ls express

Categories : Node Js

Need for module.parent in the following node.js code
If there is no module.parent it probably means that the module is being run on its own rather than being used in another program. If the !module.parent block is in a utility module I would guess that it is code for a test or developer tool. In a program that does stuff on it's own (e.g. a webserver), it would probably be the main entry point and the purpose of using it would be to make it possible to require components of that program without running the program.

Categories : Node Js

Can't install ssh2 node module
Yes, the error is that ssh2 requires node >=0.8.7 and your PATH and/or nvm setup is causing you to execute an old version of npm running under node v0.6. That is definitely the problem. Fix it by installing and correctly executing a specific version of npm with a full filesystem path instead of just npm and it will work.

Categories : Node Js

node.js export module function
require returns the exports object, so: var SessionsDAO = require('./sessions').SessionsDAO; var s = new SessionsDAO(); s.startSession(username);

Categories : Javascript

Release required module from Node.js
It sounds like you're creating some sort of plugin system. I would have a look at Node VM's: http://nodejs.org/docs/latest/api/vm.html It allows you to load and run code in a sandbox which means when it's finished all it's internal allocations should be freed again. It is marked as unstable, but that doesn't mean it doesn't work. It means the API might change in future versions of Node. As an example, Haraka, a node based smtp server, uses the VM module to (re)load plugins.

Categories : Performance

node.js expose variable to module?
You can use globals, or have a proper circular dependency (requireing both files), however - this is usually a bad habit which can lead to maintainability problems in the future. Instead, you can use dependency injection and inject doSomething into your module. This basically gives you the following for free: You can test User with a simple mock implementation of doSomething later and verify the correctness of your code The dependencies of a user are explicit and not implicit, which makes it obvious what a user needs. I'll provide two implementations, one using constructor dependency injection and one with a module wide setting. USER.JS function User(dependentFunction) { this.property = 'value'; this.doSomething = function() { var getStuff = dependentFunction(); /

Categories : Javascript

Cannot find module `mysql` node.js
It looks like you might be confused about how npm install works. npm install -g mysql will install globally not locally like you suggest. npm install mysql will install locally, putting the module in ./node_modules/mysql. This means the script you are running needs to be run from the same directory containing node_modules.

Categories : Mysql

Creating B+ tree using Postgres and adding additional field in the node of the B+ tree
Are you using the term "B+tree" differently from "B-tree"? If so, the following link in the Postgres docs might be helpful: http://www.postgresql.org/docs/current/static/xindex.html. I have no experience at all creating custom indexes so I cannot say for certain if that link will be overly helpful to you or not. Additionally in the docs: http://www.postgresql.org/about/, there is a section containing: GiST (Generalized Search Tree) indexing is an advanced system which brings together a wide array of different sorting and searching algorithms including B-tree, B+-tree, R-tree, partial sum trees, ranked B+-trees and many others. It also provides an interface which allows both the creation of custom data types as well as extensible query methods with which to search them. Thus,

Categories : Postgresql

node.js time module timezone list
Try converting the time to a common timezone before registering it with node-cron. Here's a conversion example from another question. From How to use timezone offset in Nodejs? : var time = require('time'); var a = new time.Date(1337324400000); a.setTimezone('Europe/Amsterdam'); console.log(a.toString()); // Fri May 18 2012 09:00:00 GMT+0200 (CEST) a.setTimezone('Europe/Kiev'); console.log(a.toString()); // Fri May 18 2012 10:00:00 GMT+0300 (EEST)

Categories : Javascript

node.js module self talk back to js that requires it
EventEmitter is required to create objects with event storage, and emit/catch events. While what you are using in your example is called 'callback'. It is two different ways, and can be sort of cross used. Sometimes it is good to use events, but sometimes just callback is enough. The best way to have head around it: play with callbacks (forget about events for now). Try to think of different uses of callbacks and maybe even have callback function and pass it around. Then come to callback chains. And only after start playing with EventEmitter. Remember that EventEmitter is different thing from callbacks, with sometimes compatible use cases, but generally is used in different cases. Here is your code, simplified with same functionality as you have/need atm: PDFDocument.prototype.write =

Categories : Node Js

Node.js Error: Cannot find module express
You need to install Express locally into the context of your application (node_modules folder): $ npm install express The reason for this is that applications always look in their local context for any dependencies. The global installation is only for setting up system-wide available binaries, such as unit test runners or bootstrappers or things like that. With Express, when you install it globally, you get an express binary that can bootstrap an application for you. For more information, type $ express --help So, to answer your final question: YES, you need to install it without -g.

Categories : Node Js

Catch an error on requiring module in node.js
That works fine for me as you have it. Are you sure there's no node_modules/express folder somewhere above you in the filesystem that require is finding? Try doing this to be clear about what's happening: try { var express = require('express'); console.log("Express required with no problems", express); } catch (err){ console.log("Express is not installed."); //proceed to ask if they would like to install, or quit. //command to run npm install }

Categories : Javascript

How do I avoid SELF_SIGNED_CERT_IN_CHAIN error in node.js TLS module?
Does anybody know how to solve this error and create secure connections in node? For the case of Mac OS X, you need to put the root certificate (self signed, used for signing) in your Keychain.

Categories : Node Js



© Copyright 2017 w3hello.com Publishing Limited. All rights reserved.