我在OpenShift中设置node.js时遇到了麻烦。
我已经设置了我的package.json:
{
"scripts": {
"start": "node server.js"
},
"main": "server.js",
"name": "chat",
"version": "0.0.1",
"description": "Chat",
"dependencies": {
"express": "^4.10.2",
"socket.io": "^1.2.0"
}
}
推送时出现以下错误:
$ git push
Counting objects: 776, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (709/709), done.
Writing objects: 100% (776/776), 715.32 KiB | 0 bytes/s, done.
Total 776 (delta 136), reused 0 (delta 0)
remote: [eval]:1
remote: var p = require('/var/lib/openshift/57d037442d5271a3570000ea/app-root/runtime/repo//package.json'); console.log(p.scripts.start);
remote: ^
remote:
remote: TypeError: Cannot read property 'start' of undefined
remote: at [eval]:1:122
remote: at ContextifyScript.Script.runInThisContext (vm.js:25:33)
remote: at Object.exports.runInThisContext (vm.js:77:17)
remote: at Object.<anonymous> ([eval]-wrapper:6:22)
remote: at Module._compile (module.js:556:32)
remote: at bootstrap_node.js:357:29
remote: at _combinedTickCallback (internal/process/next_tick.js:67:7)
remote: at process._tickCallback (internal/process/next_tick.js:98:9)
remote: [eval]:1
remote: var p = require('/var/lib/openshift/57d037442d5271a3570000ea/app-root/runtime/repo//package.json'); console.log(p.scripts.stop || '');
remote: ^
remote:
remote: TypeError: Cannot read property 'stop' of undefined
remote: at [eval]:1:122
remote: at ContextifyScript.Script.runInThisContext (vm.js:25:33)
remote: at Object.exports.runInThisContext (vm.js:77:17)
remote: at Object.<anonymous> ([eval]-wrapper:6:22)
remote: at Module._compile (module.js:556:32)
remote: at bootstrap_node.js:357:29
remote: at _combinedTickCallback (internal/process/next_tick.js:67:7)
remote: at process._tickCallback (internal/process/next_tick.js:98:9)
remote: CLIENT_MESSAGE: Stopping Node.js application...
Connection to oak-drabble.rhcloud.com closed by remote host.
fatal: The remote end hung up unexpectedly
fatal: The remote end hung up unexpectedly*
当我使用npm start时效果很好。我从来没有使用OpenShift,所以我不知道我是否遗漏了一些东西。我在我的回购中保留了start.js脚本,但我不知道我是否应该这样做。
关于这个问题的任何想法?
答案 0 :(得分:0)
我通过使用Node.js 0.10 cartbridge而不是Node.js(最新)解决了这个问题