Parse server migration to IBM bluemix

旧城冷巷雨未停 提交于 2020-01-04 07:33:06

问题


I am trying to run parse server with nodejs in ibm bluemix but it is throwing an error in parse server PromiseRouter file.

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

How can i get this resolved

My App .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 + '.');
});

Response :

/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

This is the function in PromiseRouter.js that is throwing an error

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;
      }
    }
  }
};

This is all i have


回答1:


The reason why Symbol is not found is because it is an ES6 feature that is not supported in your current Node.js build. Check to make sure your Node.js runtime is at least v4 (see compatibility here).

The easy way to ensure your Node.js build on Bluemix is running at least v4.0 is to define your engine variable in your app's package.json file as such:

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

After updating your package.json file, re-push your application to Bluemix and it will build it with your defined version of Node.js



来源:https://stackoverflow.com/questions/35466853/parse-server-migration-to-ibm-bluemix

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!