【发布时间】:2016-09-07 16:58:37
【问题描述】:
我在 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 脚本保存在我的 repo 中,我不知道我是否应该拥有。
对这个问题有什么想法吗?
【问题讨论】:
-
也许它没有正确提取
package.json文件,你试过console.log(p.scripts)吗? -
我应该在哪里写这个?我目前在 server.js 中只有一个简单的快速 Web 应用程序和一个 html 文件
-
这条线是 OpenShift 正在做的事情吗?
remote: var p = require('/var/lib/openshift/57d037442d5271a3570000ea/app-root/runtime/repo//package.json'); console.log(p.scripts.start);你在它下面遇到了另一个错误stop。你用什么样的框架/代码库来启动这个应用程序? -
我在文件夹中的任何地方都找不到它。我使用 express.js 和 socket.io 和 Node.js 版本 6.4.0
-
这意味着它包含在您在 OpenShift 中设置应用程序时选择的框架中。你用的是哪一个?
标签: javascript node.js openshift