Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can't run a specific version of node on openshift

I am following the steps described in this repository but I can't seem to make it work. When I look into my env file the nodejs version is still .6.20

My node js version file is the default one, so the node version .8.9 should be running. Any idea why this is happening?

My marker file:

0.8.9

Debug output when I try to start my application

==> nodejs/logs/node.log <==

npm ERR! node -v v0.6.20
npm ERR! npm -v 1.1.37
npm ERR! code ELIFECYCLE
npm ERR! message [email protected] start: `node server.js`
npm ERR! message `sh "-c" "node server.js"` failed with 1
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR!     /var/lib/openshift/51ba8386e0b8cd2873000002/app-root/runtime/repo/npm-        debug.log
npm ERR! not ok code undefined
npm ERR! not ok code 1

Just for the sake of completeness. My package.json file

{

"name": "application-name",
"version": "0.0.1",
"private": true,
"scripts": {
"start": "node server.js"
 },

"dependencies": {

    "express": "3.2.5",
    "mustache": "*",
    "request" : "*",
"buildify":"*",
"cheerio" : "*",
"slugs" : "*",
"to-markdown":"*",
"consolidate":"*"
  }
}

The app runs locally just fine.

like image 470
Akshat Jiwan Sharma Avatar asked Dec 07 '25 23:12

Akshat Jiwan Sharma


1 Answers

I like this version of the nodejs starter code better: https://github.com/ryanj/nodejs-custom-version-openshift

It contains a newer version of the .openshift application build hooks for nodejs. It will read the Marker file, but also has support for reading directly from your package.json file's engines attribute to compile your Nodejs runtime.

"engines": {
  "node": ">= 0.10.0",
  "npm": ">= 1.0.0"
},

I'm hoping to get this merged in as the default .openshift folder content for all nodejs apps on OpenShift.

You'll also want to make sure that you are binding to the NEW environment variables: OPENSHIFT_NODEJS_IP and OPENSHIFT_NODEJS_PORT. These were recently renamed.

I usually add something like this to my application code, allowing it to run anywhere:

var ip_addr = process.env.OPENSHIFT_NODEJS_IP || '127.0.0.1';
var port = process.env.OPENSHIFT_NODEJS_PORT || '8080';

OpenShift currently shows you the output from npm start, which may not reveal all of your application's output. For additional debugging info, you could try starting your app manually:

  1. First, stop your app from the command line: rhc app stop APP_NAME
  2. Then, connect to your application gear / container rhc ssh APP_NAME
  3. cd $OPENSHIFT_REPO_DIR
  4. and manually run whatever command is defined within your package.json file's scripts.start attribute.

Hopefully that gives you a bit more visibility into what is going on.

like image 178
ʀɣαɳĵ Avatar answered Dec 12 '25 13:12

ʀɣαɳĵ



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!