如何运行mongodb rest



我是节点的新手,我遵循了README文件的官方指南,我相信mongodb rest已经成功安装,但npm显示:

npm ls
/usr/local/bin
(empty)

这里没有列出mongodb rest

我根本不知道如何启动服务器,因为指南上说

 After that you can just issue mongodb-rest on the command line and the server should start.

我尝试在节点控制台中键入node mongodb-rest,甚至键入mongodb-rest,但两者都可以。帮助

更新--

感谢人们回答我的问题,我想我通过npm成功安装了mongodb-rest包,并通过键入mongodb-rest启动了mongodb rest服务器,并在README写入时使用curl在另一个终端窗口中发出http请求

curl -d '{ "A1" : 201 }' -H "Content-Type: application/json" http://localhost:3000/test/example1

我得到了curl: (52) Empty reply from server

服务器控制台中的消息:

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)

对于要全局安装模块的npm,请使用-g选项。mongodb rest的自述文件未能指定该a。

$ [sudo] npm -g install mongodb-rest

之后,命令mongodb-rest应该可以工作。

顺便说一句,要获得全局安装模块的列表,也可以在ls命令中添加-g选项。

$ npm -g ls

最新更新