如何运行mongodb-rest?
我是新来的节点,我遵循自述文件的官方指南,我相信mongodbrest成功安装,但是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
在节点控制台中键入mongodb-rest
,但任何一个工程。 帮帮我!
Update–
感谢大家回答我的问题,我想我通过npm成功安装了mongodb-rest软件包,并通过mongodb-resttypes启动了mongodb-rest服务器,并在另一个terminal窗口中使用curl作为自述文件写
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的自述文件没有指定那个。
$ [sudo] npm -g install mongodb-rest
之后,命令mongodb-rest
应该可以工作。
顺便说一句,要获得全局安装的模块列表,请在ls
命令中添加-g
选项。
$ npm -g ls