问题
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