How to run the mongodb-rest?
Question
I'm new to node, I followed the official guide on the README file, I believe the mongodb-rest is successfully installed, however npm shows:
npm ls
/usr/local/bin
(empty)
there's no mongodb-rest listed here
I simply don't know how to fire up the server as the guide says
After that you can just issue mongodb-rest on the command line and the server should start.
I try node mongodb-rest
or even type mongodb-rest
in the node console, but either one works.
Help!
Update--
Thanks to the people answer me question, I think I successfully installed the mongodb-rest package through npm, and start up the mongodb-rest server by type mongodb-rest
, and make a http request in another terminal window by using curl as the README writes
curl -d '{ "A1" : 201 }' -H "Content-Type: application/json" http://localhost:3000/test/example1
I got curl: (52) Empty reply from server
and the message in the server console:
node.js:134
throw e; // process.nextTick error, or 'error' event on first tick
^
TypeError: Cannot call method 'authenticate' of null
at /usr/local/lib/node_modules/mongodb-rest/lib/rest.js:72:10
at /usr/local/lib/node_modules/mongodb-rest/node_modules/mongodb/lib/mongodb/db.js:176:16
at [object Object].<anonymous> (/usr/local/lib/node_modules/mongodb-rest/node_modules/mongodb/lib/mongodb/connection/server.js:366:7)
at [object Object].emit (events.js:81:20)
at [object Object].<anonymous> (/usr/local/lib/node_modules/mongodb-rest/node_modules/mongodb/lib/mongodb/connection/connection_pool.js:97:15)
at [object Object].emit (events.js:67:17)
at Socket.<anonymous> (/usr/local/lib/node_modules/mongodb-rest/node_modules/mongodb/lib/mongodb/connection/connection.js:399:12)
at Socket.emit (events.js:64:17)
at Array.<anonymous> (net.js:831:12)
at EventEmitter._tickCallback (node.js:126:26)
Solution
For npm to install a module globally, use the -g
option. The readme for mongodb-rest failed to specify thata.
$ [sudo] npm -g install mongodb-rest
After, the command mongodb-rest
should work.
BTW, to get a list of globally installed modules, add the -g
option to the ls
command too.
$ npm -g ls