解析服务器NPM安装 - 内部服务器错误

时间:2016-08-24 21:13:41

标签: node.js parse-server

我完成了Parse-Serve npm安装,如下所示

$ npm install -g parse-server mongodb-runner
$ mongodb-runner start
$ parse-server --appId APPLICATION_ID --masterKey MASTER_KEY

当我尝试使用以下命令访问它时.....

 $ curl -X POST -H "X-Parse-Application-Id: AppID123" -H "Content-Type: application/json" -d '{"score":1337,"playerName":"Sean Plott","cheatMode":false}' http://localhost:1337/parse/classes/GameScore

我收到以下错误:

{"code":1,"message":"Internal server error."}

以下是运行parse-server ....

的结果
 $ parse-server --appId AppID123 --masterKey Master123

appId: AppID8Rasp
masterKey: ***REDACTED***
port: 1337
mountPath: /parse
maxUploadSize: 20mb
serverURL: http://localhost:1337/parse

parse-server running on http://localhost:1337/parse
warn: Unable to ensure uniqueness for usernames:  MongoError: failed to connect to server [localhost:27017] on first connect
    at null.<anonymous> (/usr/local/lib/node_modules/parse-server/node_modules/mongodb/node_modules/mongodb-core/lib/topologies/server.js:311:35)
    at emitOne (events.js:77:13)
    at emit (events.js:169:7)
    at null.<anonymous> (/usr/local/lib/node_modules/parse-server/node_modules/mongodb/node_modules/mongodb-core/lib/connection/pool.js:254:12)
    at g (events.js:260:16)
    at emitTwo (events.js:87:13)
    at emit (events.js:172:7)
    at Socket.<anonymous> (/usr/local/lib/node_modules/parse-server/node_modules/mongodb/node_modules/mongodb-core/lib/connection/connection.js:158:49)
    at Socket.g (events.js:260:16)
    at emitOne (events.js:77:13)
warn: Unable to ensure uniqueness for user email addresses:  MongoError: failed to connect to server [localhost:27017] on first connect
    at null.<anonymous> (/usr/local/lib/node_modules/parse-server/node_modules/mongodb/node_modules/mongodb-core/lib/topologies/server.js:311:35)
    at emitOne (events.js:77:13)
    at emit (events.js:169:7)
    at null.<anonymous> (/usr/local/lib/node_modules/parse-server/node_modules/mongodb/node_modules/mongodb-core/lib/connection/pool.js:254:12)
    at g (events.js:260:16)
    at emitTwo (events.js:87:13)
    at emit (events.js:172:7)
    at Socket.<anonymous> (/usr/local/lib/node_modules/parse-server/node_modules/mongodb/node_modules/mongodb-core/lib/connection/connection.js:158:49)
    at Socket.g (events.js:260:16)
    at emitOne (events.js:77:13)
error: Error generating response. { [MongoError: failed to connect to server [localhost:27017] on first connect]
  name: 'MongoError',
  message: 'failed to connect to server [localhost:27017] on first connect' } name=MongoError, message=failed to connect to server [localhost:27017] on first connect
error: Uncaught internal server error. { [MongoError: failed to connect to server [localhost:27017] on first connect]
  name: 'MongoError',
  message: 'failed to connect to server [localhost:27017] on first connect' } MongoError: failed to connect to server [localhost:27017] on first connect
    at null.<anonymous> (/usr/local/lib/node_modules/parse-server/node_modules/mongodb/node_modules/mongodb-core/lib/topologies/server.js:311:35)
    at emitOne (events.js:77:13)
    at emit (events.js:169:7)
    at null.<anonymous> (/usr/local/lib/node_modules/parse-server/node_modules/mongodb/node_modules/mongodb-core/lib/connection/pool.js:254:12)
    at g (events.js:260:16)
    at emitTwo (events.js:87:13)
    at emit (events.js:172:7)
    at Socket.<anonymous> (/usr/local/lib/node_modules/parse-server/node_modules/mongodb/node_modules/mongodb-core/lib/connection/connection.js:158:49)
    at Socket.g (events.js:260:16)
    at emitOne (events.js:77:13)
MongoError: failed to connect to server [localhost:27017] on first connect
    at null.<anonymous> (/usr/local/lib/node_modules/parse-server/node_modules/mongodb/node_modules/mongodb-core/lib/topologies/server.js:311:35)
    at emitOne (events.js:77:13)
    at emit (events.js:169:7)
    at null.<anonymous> (/usr/local/lib/node_modules/parse-server/node_modules/mongodb/node_modules/mongodb-core/lib/connection/pool.js:254:12)
    at g (events.js:260:16)
    at emitTwo (events.js:87:13)
    at emit (events.js:172:7)
    at Socket.<anonymous> (/usr/local/lib/node_modules/parse-server/node_modules/mongodb/node_modules/mongodb-core/lib/connection/connection.js:158:49)
    at Socket.g (events.js:260:16)
    at emitOne (events.js:77:13)

当然可以使用一些指针!感谢。

1 个答案:

答案 0 :(得分:0)

1)停止服务器。

2)安装mongodb

sudo apt-get install -y mongodb-org

3)测试以确保它正在运行

'mongod start/running, process 18777'

合适的回应是:

npm start

4)重新启动服务器:

curl -X POST -H "X-Parse-Application-Id: AppID123" -H "Content-Type: application/json" -d '{"score":1337,"playerName":"Sean Plott","cheatMode":false}' http://localhost:1337/parse/classes/GameScore

5)尝试再次创建帖子

var carryOver ={"Jan":"","Feb":""};
var parameters = getParameterByName('month')//gets the current URL parameter
if(parameters == '01-2017'){
    $('#monthQuota').html(janQuota);
    carryOver["Jan"] = 300;
}
else if(parameters == '02-2017'){
    carryOver["Feb"] = 400;
}
$(function() {
  $('parameters').on('change', function (e) {
    e.preventDefault();
    $.ajax({
        type: "POST",
        url: "utilization-2017-test.php",
        data: {
           json: JSON.stringify(monthBalances)
        }
      })
    })
 })

P.S。 &#34;本地主机&#34;应该真的是你的服务器的地址。

有更详细的解释: https://www.digitalocean.com/community/tutorials/how-to-install-mongodb-on-ubuntu-14-04