在 Bluemix 上使用 MobileFirst Services Starter 创建应用程序

Creating an application with MobileFirst Services Starter on Bluemix

我正在学习教程:https://www.ibm.com/developerworks/library/mo-android-mobiledata-app/index.html

当应用程序启动时,它会立即被阻止并停止 运行。

在activity信息频道出现如下信息:

应用程序的一个实例已被阻止:发生 2 个错误:* 发生 2 个错误:* 退出并显示状态...

我默认保留了所有内容,我在不同地区(美国南部、英国、..)尝试过,行为是一样的...

不知道是什么问题

此致

我能够重现问题。我在日志中得到的错误是:

2017-11-09T12:06:31.13-0600 [APP/PROC/WEB/0] ERR /home/vcap/app/node_modules/loopback/node_modules/strong-globalize/node_modules/os-locale/index.js:2
2017-11-09T12:06:31.13-0600 [APP/PROC/WEB/0] ERR const execa = require('execa');
2017-11-09T12:06:31.13-0600 [APP/PROC/WEB/0] ERR ^^^^^
2017-11-09T12:06:31.13-0600 [APP/PROC/WEB/0] ERR SyntaxError: Use of const in strict mode.
2017-11-09T12:06:31.13-0600 [APP/PROC/WEB/0] ERR     at exports.runInThisContext (vm.js:73:16)
2017-11-09T12:06:31.13-0600 [APP/PROC/WEB/0] ERR     at Module._compile (module.js:443:25)
2017-11-09T12:06:31.13-0600 [APP/PROC/WEB/0] ERR     at Object.Module._extensions..js (module.js:478:10)
2017-11-09T12:06:31.13-0600 [APP/PROC/WEB/0] ERR     at Module.load (module.js:355:32)
2017-11-09T12:06:31.13-0600 [APP/PROC/WEB/0] ERR     at Function.Module._load (module.js:310:12)
2017-11-09T12:06:31.13-0600 [APP/PROC/WEB/0] ERR     at Module.require (module.js:365:17)
2017-11-09T12:06:31.13-0600 [APP/PROC/WEB/0] ERR     at require (module.js:384:17)
2017-11-09T12:06:31.13-0600 [APP/PROC/WEB/0] ERR     at Object.<anonymous> (/home/vcap/app/node_modules/loopback/node_modules/strong-globalize/lib/globalize.js:13:16)
2017-11-09T12:06:31.13-0600 [APP/PROC/WEB/0] ERR     at Module._compile (module.js:460:26)
2017-11-09T12:06:31.13-0600 [APP/PROC/WEB/0] ERR     at Object.Module._extensions..js (module.js:478:10)
2017-11-09T12:06:31.18-0600 [APP/PROC/WEB/0] ERR npm ERR! Linux 4.4.0-75-generic
2017-11-09T12:06:31.18-0600 [APP/PROC/WEB/0] ERR npm ERR! argv "/home/vcap/app/vendor/node/bin/node" "/home/vcap/app/vendor/node/bin/npm" "start"
2017-11-09T12:06:31.18-0600 [APP/PROC/WEB/0] ERR npm ERR! node v0.12.18
2017-11-09T12:06:31.18-0600 [APP/PROC/WEB/0] ERR npm ERR! npm  v2.15.11
2017-11-09T12:06:31.18-0600 [APP/PROC/WEB/0] ERR npm ERR! code ELIFECYCLE
2017-11-09T12:06:31.18-0600 [APP/PROC/WEB/0] ERR npm ERR! HelloTodo@1.0.0 start: `node .`
2017-11-09T12:06:31.18-0600 [APP/PROC/WEB/0] ERR npm ERR! Exit status 1
2017-11-09T12:06:31.18-0600 [APP/PROC/WEB/0] ERR npm ERR!
2017-11-09T12:06:31.18-0600 [APP/PROC/WEB/0] ERR npm ERR! Failed at the HelloTodo@1.0.0 start script 'node .'.
2017-11-09T12:06:31.18-0600 [APP/PROC/WEB/0] ERR npm ERR! This is most likely a problem with the HelloTodo package,
2017-11-09T12:06:31.18-0600 [APP/PROC/WEB/0] ERR npm ERR! not with npm itself.
2017-11-09T12:06:31.18-0600 [APP/PROC/WEB/0] ERR npm ERR! Tell the author that this fails on your system:
2017-11-09T12:06:31.18-0600 [APP/PROC/WEB/0] ERR npm ERR!     node .
2017-11-09T12:06:31.18-0600 [APP/PROC/WEB/0] ERR npm ERR! You can get information on how to open an issue for this project with:
2017-11-09T12:06:31.18-0600 [APP/PROC/WEB/0] ERR npm ERR!     npm bugs HelloTodo
2017-11-09T12:06:31.18-0600 [APP/PROC/WEB/0] ERR npm ERR! Or if that isn't available, you can get their info via:
2017-11-09T12:06:31.18-0600 [APP/PROC/WEB/0] ERR npm ERR!
2017-11-09T12:06:31.18-0600 [APP/PROC/WEB/0] ERR npm ERR!     npm owner ls HelloTodo
2017-11-09T12:06:31.18-0600 [APP/PROC/WEB/0] ERR npm ERR! There is likely additional logging output above.
2017-11-09T12:06:31.21-0600 [APP/PROC/WEB/0] ERR npm ERR! Please include the following file with any support request:
2017-11-09T12:06:31.21-0600 [APP/PROC/WEB/0] ERR npm ERR!     /home/vcap/app/npm-debug.log

这个错误是因为 Node.js 0.12 默认不启用 ES6。正如@pradeep sg 所说,该博客 post 和启动器已经过时了。如果您查看启动程序的代码,它会在 package.json.

中指定 Node 版本 0.12

https://github.com/ibm-bluemix-mobile-services/bms-hellotodo-strongloop

要针对您的本地环境修复此问题,请下载起始代码,然后按如下方式修改 package.json

{
  "name": "HelloTodo",
  "description": "A simple todo list application created with StringLoop, LoopBack and Bluemix Mobile Services",
  "version": "1.0.0",
  "main": "server/server.js",
  "scripts": {
    "start": "node ."
  },
  "author": "Anton Aleksandrov",
  "dependencies": {
    "bluemix-appid": "1.x",
    "compression": "^1.0.3",
    "cors": "^2.5.2",
    "loopback": "^2.22.0",
    "loopback-boot": "^2.6.5",
    "loopback-component-explorer": "^2.1.0",
    "loopback-connector-mysql": "^2.2.0",
    "loopback-datasource-juggler": "^2.39.0",
    "passport": "^0.3.2",
    "serve-favicon": "^2.0.1"
  },
  "repository": {
    "type": "git",
    "url": "https://github.com/ibm-bluemix-mobile-services/bms-hellotodo-strongloop.git"
  },
  "engines": {
    "node": "8.9.x"
  },
  "license": "Apache-2.0"

然后bx cf push重新部署,所以它使用了更新的Node引擎。

在我这样做之后,它起作用了:


如果您想查找移动团队制作的最新内容,请在 Bluemix 上查看他们的仪表板:

https://console.bluemix.net/developer/mobile/dashboard

这将提供他们发布的最新入门工具包、演示、博客和内容。

我会通知他们这个问题,以便部署正常进行。