Having problems running nodeBB with redis on windows7 - node.js

I install redis on win7 by exe and I got nodeBB on
there are some first time config prompt and then
nodeBB even start populating database with default config.
After entering admin name email pwd, I got stuck here as below:
c:\Users\kaeyonbaker\Downloads\NodeBB-master\NodeBB-master\node_modules\redis\in
dex.js:535 throw err; ^ TypeError: Object # has no method 'genSalt' at
Object.User.hashPassword
(c:\Users\kaeyonbaker\Downloads\NodeBB-master\No
deBB-master\src\user.js:555:10) at
c:\Users\kaeyonbaker\Downloads\NodeBB-master\NodeBB-master\src\user.js:13
3:11 at try_callback
(c:\Users\kaeyonbaker\Downloads\NodeBB-master\NodeBB-master\
node_modules\redis\index.js:532:9) at RedisClient.return_reply
(c:\Users\kaeyonbaker\Downloads\NodeBB-master\No
deBB-master\node_modules\redis\index.js:614:13) at ReplyParser.
(c:\Users\kaeyonbaker\Downloads\NodeBB-master\Nod
eBB-master\node_modules\redis\index.js:266:14) at
ReplyParser.EventEmitter.emit (events.js:95:17) at
ReplyParser.send_reply
(c:\Users\kaeyonbaker\Downloads\NodeBB-master\Node
BB-master\node_modules\redis\lib\parser\javascript.js:300:10) at
ReplyParser.execute
(c:\Users\kaeyonbaker\Downloads\NodeBB-master\NodeBB-
master\node_modules\redis\lib\parser\javascript.js:189:22) at
RedisClient.on_data
(c:\Users\kaeyonbaker\Downloads\NodeBB-master\NodeBB-
master\node_modules\redis\index.js:488:27) at Socket.
(c:\Users\kaeyonbaker\Downloads\NodeBB-master\NodeBB-m
aster\node_modules\redis\index.js:82:14)
Then i change redis into mongo and i've got the similar error as below:
c:\Users\kaeyonbaker\Downloads\NodeBB-master\NodeBB-master\node_modules\mongodb\
lib\mongodb\connection\base.js:242 throw message; ^ TypeError: Object#
has no method 'genSalt' at Object.User.hashPassword (c:\Users\kaeyonbaker\Downloads\NodeBB-master\No
deBB-master\src\user.js:555:10) at
c:\Users\kaeyonbaker\Downloads\NodeBB-master\NodeBB-master\src\user.js:13
3:11 at
c:\Users\kaeyonbaker\Downloads\NodeBB-master\NodeBB-master\src\database\m
ongo.js:418:5 at
c:\Users\kaeyonbaker\Downloads\NodeBB-master\NodeBB-master\node_modules\m
ongodb\lib\mongodb\collection\core.js:703:14 at
c:\Users\kaeyonbaker\Downloads\NodeBB-master\NodeBB-master\node_modules\m
ongodb\lib\mongodb\db.js:1098:5 at
c:\Users\kaeyonbaker\Downloads\NodeBB-master\NodeBB-master\node_modules\m
ongodb\lib\mongodb\db.js:1806:9 at Server.Base.callHandler
(c:\Users\kaeyonbaker\Downloads\NodeBB-master\No
deBB-master\nodemodules\mongodb\lib\mongodb\connection\base.js:442:41)
at
c:\Users\kaeyonbaker\Downloads\NodeBB-master\NodeBB-master\node_modules\m
ongodb\lib\mongodb\connection\server.js:485:18 at MongoReply.parseBody
(c:\Users\kaeyonbaker\Downloads\NodeBB-master\NodeBB
-master\node_modules\mongodb\lib\mongodb\responses\mongo_reply.js:68:5)
at null. (c:\Users\kaeyonbaker\Downloads\NodeBB-master\NodeBB-mas
ter\node_modules\mongodb\lib\mongodb\connection\server.js:443:20)

Related

Line number error does not show up when using MSSQL Node?

I have been using MySQL database with Nodejs for a while. I recently switched to MSSQL with Nodejs
When using a try catch block with Nodejs and Mysql any error with the query execution would give me the line at which the error occured
So while using MySQL I did:
try{
await pool.quer(`sql statement`)
}
catch(err){
console.log(err)
}
This would give me an error and the line number of error. But with node-mssql, I get:
{ RequestError: Incorrect syntax near 'Invalid'.
at StreamEvents.req.once.err (C:\Users\David\Main Web\node_modules\mssql\lib\msnodesqlv8\request.js:463:17)
at Object.onceWrapper (events.js:277:13)
at StreamEvents.emit (events.js:189:13)
at errors.forEach.err (C:\Users\David\Main Web\node_modules\msnodesqlv8\lib\reader.js:33:20)
at Array.forEach (<anonymous>)
at routeStatementError (C:\Users\David\Main Web\node_modules\msnodesqlv8\lib\reader.js:26:14)
at invokeObject.end (C:\Users\David\Main Web\node_modules\msnodesqlv8\lib\reader.js:258:13)
at freeStatement (C:\Users\David\Main Web\node_modules\msnodesqlv8\lib\driver.js:160:13)
at cppDriver.freeStatement (C:\Users\David\Main Web\node_modules\msnodesqlv8\lib\driver.js:150:11)
code: 'EREQUEST',
originalError:
{ Error: [Microsoft][SQL Server Native Client 11.0][SQL Server]Incorrect syntax near 'Invalid'. sqlstate: '42000', code: 102 },
name: 'RequestError',
number: 102,
state: undefined }
This is such an unhelpful error. I know where the error is coming from for this error because there is only one sql statement getting executed right now but as my program grows without knowing where the error is coming from it will be hard to debug. Is this an expected behavior of node-mssql?
If you see the documentation here, it clearly mentions what it return in error and what not.
It clearly mentions that "Those errors are initialized in node-mssql module and its original stack may be cropped. You can always access original error with err.originalError"
In your catch block you can try printing the stack trace. That should give you the line number where the error occurred. You can use one of the following statements:
console.stack("---TRACE---")
OR
var stackTrace = new Error().stack
console.log(stackTrace)

How to use "node_redis" in a phantomjs script?

I want make a phantomjs script that actuates as consumer process reading values from a redis server. I see that exists this client for node (https://github.com/NodeRedis/node_redis) and I connect, write and read without problem executing a node script.
var redis = require("redis"),
client = redis.createClient();
client.on("error", function (err) {
console.log("Error " + err);
});
client.set("string key", "string val", redis.print);
client.get("string key", redis.print);
But when I do the same with phantomjs I obtain this error:
ReferenceError: Can't find variable: process
phantomjs://platform/command.js:4
TypeError: undefined is not a constructor (evaluating 'util.inherits(assert.AssertionError, Error)')
phantomjs://platform/assert.js:161
TypeError: undefined is not a constructor (evaluating 'util.inherits(RedisError, Error)')
phantomjs://platform/redisError.js:17
TypeError: undefined is not a constructor (evaluating 'util.inherits(ReplyError, RedisError)')
phantomjs://platform/replyError.js:16
TypeError: undefined is not a constructor (evaluating 'util.inherits(ParserError, RedisError)')
phantomjs://platform/parserError.js:18
ReferenceError: Can't find variable: Buffer
phantomjs://platform/parser.js:22 in bufferAlloc
phantomjs://platform/parser.js:8
TypeError: undefined is not a constructor (evaluating 'util.inherits(AbortError, RedisError)')
phantomjs://platform/customErrors.js:43
Error: Cannot find module 'events'
phantomjs://platform/bootstrap.js:299 in require
phantomjs://platform/bootstrap.js:263 in require
Is there any way to use this package with phantomjs?
PhantomJS is not compatible with node.js, you can't use this package in it.
Your best bet is to use some node.js bridge for PhantomJS, like https://github.com/amir20/phantomjs-node or https://github.com/baudehlo/node-phantom-simple and then use node_redis in that node.js script.

MongoError: write EPIPE

I'm using Node.JS + Mongoose + MongoDB. Had my app working ok until now, now when trying to save a document:
Saving operation:
doc.save(function(err, d){
console.log(err,d);
{"name":"MongoError","message":"write EPIPE"}
Error stack:
{ [MongoError: server localhost:27017 received an error {"name":"MongoError","message":"write EPIPE"}]
name: 'MongoError',
message: 'server localhost:27017 received an error {"name":"MongoError","message":"write EPIPE"}' } undefined
error: TypeError: Cannot read property 'url' of undefined
at EventEmitter.<anonymous> (/home/ec2-user/c/index.js:160:61)
at EventEmitter.<anonymous> (/home/ec2-user/c/node_modules/mongoose/node_modules/mpromise/lib/promise.js:174:48)
at EventEmitter.emit (events.js:95:17)
at Promise.safeEmit (/home/ec2-user/c/node_modules/mongoose/node_modules/mpromise/lib/promise.js:81:21)
at Promise.reject (/home/ec2-user/c/node_modules/mongoose/node_modules/mpromise/lib/promise.js:109:15)
at Promise.error (/home/ec2-user/c/node_modules/mongoose/lib/promise.js:94:15)
at Promise.resolve (/home/ec2-user/c/node_modules/mongoose/lib/promise.js:112:24)
at /home/ec2-user/c/node_modules/mongoose/lib/document.js:1555:39
at handleError (/home/ec2-user/c/node_modules/mongoose/node_modules/hooks-fixed/hooks.js:40:22)
at next_ (/home/ec2-user/c/node_modules/mongoose/node_modules/hooks-fixed/hooks.js:75:26)
Looks like I'm able to read data, but not to write new documents. Mongo is app and running. I've tried so far, restarting the DB, with no good results.
Just tried to insert from mongo client and worked
> db.mysecretcollection.insert({url:"sampletestremoveme"});
WriteResult({ "nInserted" : 1 })
So it seems to be a Node.js / Mongoose issue.
It seems to me that the document was too big, actually I was able to save it after removing one of its fields. The weird thing is that mongoose should catch that with "Error: Document exceeds maximum allowed bson size of XXX bytes" exception, but that was never thrown.

The strange Node.js error after starting script

I use Node.js.
My server js script I run such:
node chat_server.js
After I get errors messages in terminal CentOS:
Express server listening on port undefined in development mode.
+ User undefined connected node_redis: no callback to send error: ERR wrong number of arguments for 'sadd' command
/home/who/public_html/node/node_modules/redis/index.js:582
throw err;
^ Error: ERR wrong number of arguments for 'sadd' command
at ReplyParser. (/home/who/public_html/node/node_modules/redis/index.js:317:31)
at ReplyParser.emit (events.js:95:17)
at ReplyParser.send_error (/home/who/public_html/node/node_modules/redis/lib/parser/javascript.js:296:10)
at ReplyParser.execute (/home/who/public_html/node/node_modules/redis/lib/parser/javascript.js:181:22)
at RedisClient.on_data (/home/who/public_html/node/node_modules/redis/index.js:547:27)
at Socket. (/home/who/public_html/node/node_modules/redis/index.js:102:14)
at Socket.emit (events.js:95:17)
at Socket. (_stream_readable.js:748:14)
at Socket.emit (events.js:92:17)
at emitReadable_ (_stream_readable.js:410:10)
Excuse me, but I do not understand the reason of these errors.
On what I should get attention and how fix it?
For example, I use command redis SADD: redis_cli.sadd( "user.friend:" + currentIdUser, data.idUser);
I have done a experiment, created a new text script:
var redis = require("redis");
var client = redis.createClient();
client.on("error", function (err) {
console.log("Error " + err);
});
client.sadd("users","naveen",function(err,reply){
console.log('Ok');
if(err)
throw err;
return reply;
});
It have given me in console: OK. It mean, that all works fine.
I think in my code:
redis_cli.sadd("userslist", currentIdUser);
the variable currentUser is simply empty or undefined. It gives me the next errors.
Problem was at my script in line:
redis_cli.sadd("userslist", currentIdUser);
The variable is undefined. It calls error redis.
Thank you all for help.

Node Redis Client Not Working With Method "HMSET"

I have the following code block that fails:
this.redisClient.hmset('user:' + userObj.getUserId(), {
'userId' : userObj.getUserId(),
'salutation' : userObj.getSalutation(),
'fn' : userObj.getFn(),
'mi' : userObj.getMi(),
'ln' : userObj.getLn(),
'suffix' : userObj.getSuffix(),
'userType' : userObj.getUserType(),
'created' : userObj.getCreated()
});
The error stack is as follows:
node.js:201
throw e; // process.nextTick error, or 'error' event on first tick
^
TypeError: Cannot call method 'hmset' of undefined
at /node_apps/oc/api/v1/routes/user/db.user.js:70:34
at try_callback (/node_apps/oc/api/v1/node_modules/redis/index.js:484:9)
at RedisClient.return_reply (/node_apps/oc/api/v1/node_modules/redis/index.js:555:13)
at HiredisReplyParser.<anonymous> (/node_apps/oc/api/v1/node_modules/redis/index.js:256:14)
at HiredisReplyParser.emit (events.js:67:17)
at HiredisReplyParser.execute (/node_apps/oc/api/v1/node_modules/redis/lib/parser/hiredis.js:43:18)
at RedisClient.on_data (/node_apps/oc/api/v1/node_modules/redis/index.js:440:27)
at Socket.<anonymous> (/node_apps/oc/api/v1/node_modules/redis/index.js:70:14)
at Socket.emit (events.js:67:17)
at TCP.onread (net.js:329:14)
I am running Node 0.6.17 with Node Redis client. Any insight? Thanks!
If Node thinks you're calling hmset on undefined, that means it thinks that this.redisClient is undefined; quite often, this is because the value of this is not what you think it is (although it could be that redisClient wasn't initialized, etc). While it's impossible to say without seeing the surrounding code and how it's called, check to make sure the value of this is bound, if necessary.

Resources