2

我正在尝试在 ibm bluemix 中使用 nodejs 运行解析服务器,但它在解析服务器 PromiseRouter 文件中引发错误。

PromiseRouter.js:48
        throw _iteratorError;
              ^
ReferenceError: Symbol is not defined

我怎样才能解决这个问题

我的应用程序.js

var express = require('express');
var ParseServer = require('parse-server').ParseServer;

var app = express();

var port = process.env.PORT || 1337;

// Specify the connection string for your mongodb database 
// and the location to your Parse cloud code 
var api = new ParseServer({
  databaseURI: 'mongodb://IBM_MONGO_DB',
  cloud: './cloud/main.js', // Provide an absolute path 
  appId: 'MYAPPID',
  masterKey: 'MYMASTER_KEY', //Add your master key here. Keep it secret! 
  serverURL: 'http://localhost:' + port + '/parse' // Don't forget to change to https if needed 
});
app.use('/parse', api);
app.get('/', function(req, res) {
  res.status(200).send('Express is running here.');
});

app.listen(port, function() {
  console.log('parse-server-example running on port ' + port + '.');
});

回复 :

/Applications/MAMP/htdocs/IBM_bluemix/Development/my_node_app/node_modules/parse-server/lib/PromiseRouter.js:48
        throw _iteratorError;
              ^
ReferenceError: Symbol is not defined
    at PromiseRouter.merge (/Applications/MAMP/htdocs/IBM_bluemix/Development/my_node_app/node_modules/parse-server/lib/PromiseRouter.js:33:40)
    at new ParseServer (/Applications/MAMP/htdocs/IBM_bluemix/Development/my_node_app/node_modules/parse-server/lib/index.js:137:10)
    at Object.<anonymous> (/Applications/MAMP/htdocs/IBM_bluemix/Development/my_node_app/app.js:10:11)
    at Module._compile (module.js:456:26)
    at Object.Module._extensions..js (module.js:474:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:312:12)
    at Function.Module.runMain (module.js:497:10)
    at startup (node.js:119:16)
    at node.js:906:3

这是 PromiseRouter.js 中抛出错误的函数

PromiseRouter.prototype.merge = function (router) {
  var _iteratorNormalCompletion = true;
  var _didIteratorError = false;
  var _iteratorError = undefined;

  try {
    for (var _iterator = router.routes[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
      var route = _step.value;

      this.routes.push(route);
    }
  } catch (err) {
    _didIteratorError = true;
    _iteratorError = err;
  } finally {
    try {
      if (!_iteratorNormalCompletion && _iterator.return) {
        _iterator.return();
      }
    } finally {
      if (_didIteratorError) {
        throw _iteratorError;
      }
    }
  }
};

这就是我所拥有的

4

1 回答 1

3

Symbol找不到的原因是因为它是您当前的 Node.js 构建中不支持的ES6 功能。检查以确保您的 Node.js 运行时至少为 v4(请参阅此处的兼容性)。

确保在 Bluemix 上构建的 Node.js 至少运行 v4.0 的简单方法是engine在应用程序package.json文件中定义变量,如下所示:

{ "engines" : { "node" : ">=4.0" } }

更新package.json文件后,将应用程序重新推送到 Bluemix,它将使用您定义的 Node.js 版本构建它

于 2016-02-17T22:25:45.540 回答