在 Bluemix 上使用 MobileFirst Services Starter 创建应用程序
Posted
技术标签:
【中文标题】在 Bluemix 上使用 MobileFirst Services Starter 创建应用程序【英文标题】:Creating an application with MobileFirst Services Starter on Bluemix 【发布时间】:2017-11-08 11:50:28 【问题描述】:我正在学习教程:https://www.ibm.com/developerworks/library/mo-android-mobiledata-app/index.html
当应用程序启动时,它立即被阻塞并停止运行。
在活动信息频道出现如下信息:
应用实例已被阻止:发生 2 个错误:* 发生 2 个错误:* Exited with stat...
默认情况下我已经保留了所有内容,并且我在不同的地区(美国南部、英国……)进行了尝试,并且行为是相同的……
我不知道是什么问题。
问候
【问题讨论】:
@atanony 您指的是开发者作品中的旧博客,您能否通过以下 youtube 链接和 github 链接了解有关如何使用 android 应用程序进行推送通知的更多信息。 youtube.com/watch?v=Fza8kj74Lqsgithub.com/ibm-bluemix-mobile-services/… @pradeep-sg 感谢您的评论和链接。 【参考方案1】:我能够重现该问题。我在日志中得到的错误是这样的:
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 所说,该博客文章和启动器已经过时了。如果您查看启动器的代码,它会在 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
这将提供最新的入门工具包、演示、博客和他们正在发布的内容。
我会通知他们这个问题,以便部署正常工作。
【讨论】:
非常感谢您的解决方案!完美运行。以上是关于在 Bluemix 上使用 MobileFirst Services Starter 创建应用程序的主要内容,如果未能解决你的问题,请参考以下文章
无法在 Bluemix 上的 MobileFirst 容器上配置 Cloudant 数据代理
在 Bluemix-MobileFirst Foundation 上部署适配器
Bluemix 上的 MobileFirst JavaAdapter