openshift with nodejs isn't respecting the path to my server file in package.json

一世执手 提交于 2020-01-01 19:48:47

问题


I have been working on a Node.js server and am now uploading it to OpenShift. I am not using the default ./server.js file, but rather, my insertion point is ./bin/www.

I have set this as the insertion file in package.json like so:

{
  "name": "NekoList",
  "version": "0.0.0",
  "private": true,
  "scripts": {
    "start": "./bin/www"
...
},

I can verify that www is in the ./bin this directory, and it is a valid javascript file that functions perfectly well on my local environment.

This is according to here

However, I can tell from my logs that OpenShift is still trying to find ./server.js

What might be going on here? What other information can I post that would be helpful?

Note: This is related to the problem in this thread, but, when I realized the problem was not actually a dependency issue, I decided to create a new thread for the real issue.


回答1:


You are using the "scripts" property, but on OpenShift you need to use "main" instead. This is because OpenShift uses node-supervisor to startup and manage your Node.js application.




回答2:


Okay I think I have found the problem.

From the information you provided and the one on here : Markers files for Node.js, you will have to add the marker 'use_npm' for using the npm start to start the server (where it looks for the start script provided in scripts section on your package.json) instead of : supervisor <whatever-you-gave-for-main-on-package.json.

So you will have to add an empty file named use_npm under .openshift/markers. Then commit the changes and deploy. It should then start the server with ./bin/www of your project and also you will still have to use node $OPENSHIFT_REPO_DIR/bin/www for start on package.json.

Btw, you haven't given here what you gave for the main section on package.json.



来源:https://stackoverflow.com/questions/30637181/openshift-with-nodejs-isnt-respecting-the-path-to-my-server-file-in-package-jso

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