install mongodb with node.js: Cannot read property 'arbiterOnly' of undefined - node.js

I try to install remotely node.js + now.js + mongoDB on a newly created Ubuntu 11.04 system (64 bits).
I created a structure like this:
/home/xxx/server.js
/home/xxx/node/
/home/xxx/node_modules/now/
/home/xxx/http/index.html
No problem with node.js and now.js, it works just fine but I have a hard time trying to install and setup mongoDB.
I went to the root of my machine and installed Mongodb this way:
cd
sudo apt-get install mongodb
I don't know if I should but I created a data/db folder like this:
cd
mkdir /data/db
chown `id -u` /data/db
When done, I installed the mongodb driver for node on the appropriate folder:
cd /home/xxx/
npm install mongodb
Then I started the node server. My static page appears as it should but this is what I get on the ssh terminal after about 10 seconds:
[TypeError: Cannot read property 'arbiterOnly' of undefined]
TypeError: Cannot read property 'arbiterOnly' of undefined
at /home/xxx/node_modules/mongodb/lib/mongodb/connection/server.js:558:22
at [object Object].checkoutReader (/home/xxx/node_modules/mongodb/lib/mongodb/connection/server.js:575:16)
at /home/xxx/node_modules/mongodb/lib/mongodb/db.js:1344:79
at Db._executeQueryCommand (/home/xxx/node_modules/mongodb/lib/mongodb/db.js:1555:5)
at Cursor.nextObject (/home/xxx/node_modules/mongodb/lib/mongodb/cursor.js:455:13)
at Array.0 (/home/xxx/node_modules/mongodb/lib/mongodb/cursor.js:162:12)
at EventEmitter._tickCallback (node.js:192:40)
Tue Apr 24 2012 07:12:45 GMT+0200 (CEST) [GET] http://www.verysurf.com/proxyheader.php
error loading file httphttp://www.verysurf.com/proxyheader.php: { [Error: ENOENT, No such file or directory 'httphttp://www.verysurf.com/proxyheader.php']
errno: 33,
code: 'ENOENT',
path: 'httphttp://www.verysurf.com/proxyheader.php' }
What is this 'arbiterOnly' error message about?
What do I do wrong?
I googled this thing but there's not much to find about it.
And that "www.verysurf.com" url at the end of the error message, it's not always the same one. 5 minutes before I got this one (and I didn't change anything, just restarted the node server):
error loading file httphttp://59.53.91.9/proxy/judge.php: { [Error: ENOENT, No such file or directory 'httphttp://59.53.91.9/proxy/judge.php']
errno: 33,
code: 'ENOENT',
path: 'httphttp://59.53.91.9/proxy/judge.php' }
I really don't know what these url's are about.
Any help please?
Thank you.

I don't know why it's triggering that particular error message, but it looks to me like someone is or someones are sniffing your webserver to see if it's an open proxy (which it isn't). Some HTTP servers, notably Apache, are easily misconfigured to proxy any request to a third party:
http://en.wikipedia.org/wiki/Open_proxy

I get the very same message ([TypeError: Cannot read property 'arbiterOnly' of undefined]) when trying to request the database before the connection is fully initialized.
Make sure db.open() has finished (successfully)

Related

Hexo init fail on windows 10

When I try to run hexo init in Git Bash in Windows10, it fail and show following :
INFO Cloning hexo-starter https://github.com/hexojs/hexo-starter.git
fatal: unable to access 'https://github.com/hexojs/hexo-starter.git/': Failed to connect to localhost port 1080: Connection refused
WARN git clone failed. Copying data instead
FATAL {
err: [Error: ENOENT: no such file or directory, scandir 'C:\Users\Administrator\AppData\Roaming\npm\node_modules\hexo-cli\assets'] {
errno: -4058,
code: 'ENOENT',
syscall: 'scandir',
path: 'C:\\Users\\Administrator\\AppData\\Roaming\\npm\\node_modules\\hexo-cli\\assets'
}
} Something's wrong. Maybe you can find the solution here: %s http://hexo.io/docs/troubleshooting.html
How does it happen and how do we solve it?
I had the issue too. Tried again after a few minutes it worked. It due to bad access to github.com from China.
Try to run the same command from powershell non admin. If it does not work, try npx hexo init

Sailsjs: Server crash after using create blueprint with mongodb

I configured the connections.js file in config. I used shortcut route to check whether data is getting stored in the database.
I put the url localhost:1337/test/create?name=hello
It creates an entry in the database but server crashes with this log
process.nextTick(function() { throw err; });
^
TypeError: Right-hand side of 'instanceof' is not callable
at _hasBinary (/usr/local/lib/node_modules/sails/node_modules/has-binary/index.js:31:30)
at hasBinary (/usr/local/lib/node_modules/sails/node_modules/has-binary/index.js:58:10)
at Namespace.emit (/usr/local/lib/node_modules/sails/node_modules/socket.io/lib/namespace.js:214:9)
at Object.broadcastToRoom [as broadcast] (/usr/local/lib/node_modules/sails/node_modules/sails-hook-sockets/lib/sails.sockets/broadcast-to-room.js:74:13)
at child.broadcast (/usr/local/lib/node_modules/sails/lib/hooks/pubsub/index.js:139:23)
at child.publishCreateSingle (/usr/local/lib/node_modules/sails/lib/hooks/pubsub/index.js:1218:14)
at /usr/local/lib/node_modules/sails/lib/hooks/pubsub/index.js:1069:16
at arrayEach (/usr/local/lib/node_modules/sails/node_modules/#sailshq/lodash/lib/index.js:1439:13)
at Function.<anonymous> (/usr/local/lib/node_modules/sails/node_modules/#sailshq/lodash/lib/index.js:3500:13)
at child.publishCreate (/usr/local/lib/node_modules/sails/lib/hooks/pubsub/index.js:1068:11)
at child.wrapper [as publishCreate] (/usr/local/lib/node_modules/sails/node_modules/#sailshq/lodash/lib/index.js:3250:19)
at created (/usr/local/lib/node_modules/sails/lib/hooks/blueprints/actions/create.js:48:19)
at wrapper (/usr/local/lib/node_modules/sails/node_modules/lodash/index.js:3592:19)
at applyInOriginalCtx (/usr/local/lib/node_modules/sails/node_modules/waterline/lib/waterline/utils/normalize.js:421:80)
at wrappedCallback (/usr/local/lib/node_modules/sails/node_modules/waterline/lib/waterline/utils/normalize.js:324:18)
at success (/usr/local/lib/node_modules/sails/node_modules/waterline/node_modules/switchback/lib/normalize.js:33:31)
at _switch (/usr/local/lib/node_modules/sails/node_modules/waterline/node_modules/switchback/lib/factory.js:58:28)
at /usr/local/lib/node_modules/sails/node_modules/waterline/lib/waterline/query/dql/create.js:248:9
at /usr/local/lib/node_modules/sails/node_modules/waterline/node_modules/async/lib/async.js:52:16
at /usr/local/lib/node_modules/sails/node_modules/waterline/node_modules/async/lib/async.js:269:32
at /usr/local/lib/node_modules/sails/node_modules/waterline/node_modules/async/lib/async.js:44:16
at child.<anonymous> (/usr/local/lib/node_modules/sails/node_modules/waterline/lib/waterline/utils/schema.js:152:44)
Update:20-Dec-2017..
This is what i had gotten when in installed the >sails-mongo adapter...What exactly is the version 2.1.20 of..?
Faizaans-MacBook-Pro:foobar faiz$ npm install sails-mongo --save
npm WARN deprecated mongodb#2.1.20: Please upgrade to 2.2.19 or higher
+ sails-mongo#0.12.2
added 14 packages in 7.967s
I couldn't figure out the exact issue here. I tried to connect my project to mysql and the same issue came up. The problem got solved when I created a new project and tried connecting it to the database.

jsreport failing on looking up extensions

So I recently started working on a linux machine (ubuntu 16.04) and followed the installation instructions here http://jsreport.net/downloads/. When I run npm start --production I get
2016-09-13T16:51:57.134Z - info: Initializing jsreport in production mode using configuration file prod.config.json
2016-09-13T16:51:57.138Z - info: Setting process based strategy for rendering. Please visit http://jsreport.net/learn/configuration for information how to get more performance.
2016-09-13T16:51:57.146Z - info: Searching for available extensions in /home/ross/rifiniti/optimo_ui/
2016-09-13T16:51:57.152Z - info: Extensions location cache not found, crawling directories
2016-09-13T16:51:57.317Z - error: Error occured during reporter init Error: ENOENT, no such file or directory '/home/ross/rifiniti/optimo_ui/ember/tmp/tree_merger-tmp_dest_dir-2yGnPLMA.tmp/optimo-ui/config'
at Error (native)
at Object.fs.statSync (fs.js:801:18)
at /home/ross/rifiniti/optimo_ui/node_modules/jsreport/node_modules/jsreport-core/lib/util/util.js:51:21
at Array.forEach (native)
at Object.exports.walkSync (/home/ross/rifiniti/optimo_ui/node_modules/jsreport/node_modules/jsreport-core/lib/util/util.js:44:10)
at /home/ross/rifiniti/optimo_ui/node_modules/jsreport/node_modules/jsreport-core/lib/extensions/locationCache.js:50:20
From previous event:
at /home/ross/rifiniti/optimo_ui/node_modules/jsreport/node_modules/jsreport-core/lib/reporter.js:90:8
From previous event:
at Reporter.init (/home/ross/rifiniti/optimo_ui/node_modules/jsreport/node_modules/jsreport-core/lib/reporter.js:69:30)
at Reporter.reporter.init (/home/ross/rifiniti/optimo_ui/node_modules/jsreport/lib/extendInit.js:8:21)
at Object.<anonymous> (/home/ross/rifiniti/optimo_ui/server.js:1:85)
And I have no idea why. It was working fine on mac but now it is looking for this non-existent tmp file in ember. I'm at a loss, any help would be greatly appreciated!
SOLVED!
All I had to do was remove the tmp directory in ember and it worked.

node application getting "Error: EACCES: permission denied, mkdir '.tmp'

I am running node-red on my raspberry pi and am trying to get a node that I wrote myself working on it. The node works fine on my windows PC but I haven't been able to get it working on my pi yet.
My node uses mailin to setup an SMTP server but I don't think it's an issue with that package.
mailin is trying to create a temporary folder but it obviously doesn't have permissions. How do I give node the permissions it needs to be able to create this folder?
full error:
5 Apr 20:06:22 - [info] Starting flows
shell.js: internal error
Error: EACCES: permission denied, mkdir '.tmp'
at Error (native)
at Object.fs.mkdirSync (fs.js:794:18)
at mkdirSyncRecursive (/home/pi/.node-red/node_modules/node-red-contrib-mailin-smtp/node_modules/mailin/node_modules/shelljs/src/mkdir.js:11:8)
at /home/pi/.node-red/node_modules/node-red-contrib-mailin-smtp/node_modules/mailin/node_modules/shelljs/src/mkdir.js:63:7
at Array.forEach (native)
at Object._mkdir (/home/pi/.node-red/node_modules/node-red-contrib-mailin-smtp/node_modules/mailin/node_modules/shelljs/src/mkdir.js:48:8)
at Object.mkdir (/home/pi/.node-red/node_modules/node-red-contrib-mailin-smtp/node_modules/mailin/node_modules/shelljs/src/common.js:186:23)
at Mailin.start (/home/pi/.node-red/node_modules/node-red-contrib-mailin-smtp/node_modules/mailin/lib/mailin.js:73:15)
at new MailinSMTP (/home/pi/.node-red/node_modules/node-red-contrib-mailin-smtp/mailinSMTP.js:15:10)
at createNode (/usr/lib/node_modules/node-red/red/runtime/nodes/flows/Flow.js:276:18)
at Flow.start (/usr/lib/node_modules/node-red/red/runtime/nodes/flows/Flow.js:64:35)
at start (/usr/lib/node_modules/node-red/red/runtime/nodes/flows/index.js:264:29)
at tryCatchReject (/usr/lib/node_modules/node-red/node_modules/when/lib/makePromise.js:845:30)
at runContinuation1 (/usr/lib/node_modules/node-red/node_modules/when/lib/makePromise.js:804:4)
at Fulfilled.when (/usr/lib/node_modules/node-red/node_modules/when/lib/makePromise.js:592:4)
at Pending.run (/usr/lib/node_modules/node-red/node_modules/when/lib/makePromise.js:483:13)
nodered.service: main process exited, code=exited, status=1/FAILURE
Many Thanks
The problem here was that mailin was trying to create a temp folder within the root folder for node which was not allowed. Looking at the code for mailin though I was able to pass a different folder to use for temporary files. I did this by adding a tmp property to the config object and set it to os.tempdir()/mailin

how to push data into mongodb using sparkfun phant?

I am new to phant and i cannot find a suitable documentation on phant using mongodb. because i have lots of data and it memory overflow occurs. and finally i fell into following error:
HTTP output: { [Error: EMFILE, open 'phant_streams/4d16/83403f7611e5810d57f88174fbef/stream.csv']
errno: -24,
code: 'EMFILE',
path: 'phant_streams/4d16/83403f7611e5810d57f88174fbef/stream.csv' }
events.js:87
throw Error('Uncaught, unspecified "error" event.');
^
Error: Uncaught, unspecified "error" event.
at Error (native)
at Function.emit (events.js:87:13)
at Function.<anonymous> (/usr/lib/node_modules/phant/node_modules/phant-manager-http/index.js:237:12)
at PhantMeta.<anonymous> (/usr/lib/node_modules/phant/node_modules/phant-meta-nedb/lib/phant-meta-nedb.js:243:14)
at callback (/usr/lib/node_modules/phant/node_modules/phant-meta-nedb/node_modules/nedb/lib/executor.js:30:17)
at /usr/lib/node_modules/phant/node_modules/phant-meta-nedb/node_modules/nedb/lib/datastore.js:536:25
at /usr/lib/node_modules/phant/node_modules/phant-meta-nedb/node_modules/nedb/lib/persistence.js:201:12
at fs.js:1077:21
at FSReqWrap.oncomplete (fs.js:95:15)
except this sometimes following error also occurs:
FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - process out of memory
thats why i want to use mongodb to prevent this error. i searched about this and finally found sparckfun library for mongodb:
https://github.com/sparkfun/phant-stream-mongodb
i installed this but nothing happened as data still not string into mongo.
so, How will i store phant data into mongodb ?
I had the same problem, specifically trying to deploy my own Phant instance on Heroku (since I wanted to circumvent Sparkfun's 50Mb limit). After some dabbling with versions of the mongodb and mongoose libraries, I successfully forked and modified their repository so that you can either run it locally or directly deploy on heroku (just make sure you provision a MongoLab add-on). Check out my fork here: https://github.com/davidlago/phant
Hope this helps!

Resources