OpenShift does not work with certain Nodejs (Koa) dependencies

I checked How to configure KoaJS in Openshift and it still does not work.

Here is part of my package.json file:

  "engines": { "node": ">= 0.12.0", "npm": ">= 1.0.0" }, "dependencies": { "co-busboy": "^1.3.0", "forever": "^0.14.1", "fs": "0.0.2", "koa": "^0.18.1", "koa-logger": "^1.2.2", "koa-router": "^4.2.0", "koa-static": "^1.4.9", "path": "^0.11.14" }, "devDependencies": {}, "bundleDependencies": [], "private": true, "main": "--harmony app.js" 

And then to my app.js file.

This code works:

 var http = require('http'); //var koa = require('koa'); //var app = koa(); var ip = process.env.OPENSHIFT_NODEJS_IP || '127.0.0.1', port = process.env.OPENSHIFT_NODEJS_PORT || '8080'; http.createServer(function (req, res) { res.writeHead(200, {'Content-Type': 'text/plain'}); res.end('Hello World\n'); }).listen(port, ip); console.log('Server running at http://'+ip+':'+port+'/'); 

This does not work:

 var http = require('http'); var koa = require('koa'); var app = koa(); var ip = process.env.OPENSHIFT_NODEJS_IP || '127.0.0.1', port = process.env.OPENSHIFT_NODEJS_PORT || '8080'; http.createServer(function (req, res) { res.writeHead(200, {'Content-Type': 'text/plain'}); res.end('Hello World\n'); }).listen(port, ip); console.log('Server running at http://'+ip+':'+port+'/'); 

As you can see, the only difference is that I have uncommented two lines.

Error:

 Service Temporarily Unavailable The server is temporarily unable to service your request due to maintenance downtime or capacity problems. Please try again later. Apache/2.2.15 (Red Hat) Server at fela-basickarl.rhcloud.com Port 80 

The error log in OpenShift reports the following:

 ... .../app-root/runtime/repo/node_modules/koa/lib/application.js:179 function *respond(next) { ^ SyntaxError: Unexpected token * ... 

Great spirit.

console.log(process.versions); shows that I am using node 0.10.25 , although I stated in package.json that I want to use >= 0.12.0 :

 { http_parser: '2.0', node: '0.10.25', v8: '3.14.5.10', ares: '1.9.1', uv: '0.10.23', zlib: '1.2.3', modules: '11', openssl: '1.0.0-fips' } 

What causes OpenShift to not use 0.12.2?

+4
source share
1 answer

Quick Deploy 0.12

https://hub.openshift.com/quickstarts/128-node-js-0-12

For people who want to reset the nodejs 0.12 node, use the link above, there is a Deploy button.

0.12.2

To deploy a specific version 0.12.2 copy the .openshift directory from https://github.com/ryanj/nodejs-custom-version-openshift and overwrite the current .openshift projects (I assume you are using the OpenShifts git that was created when the application was created )

Go to your-project/.openshift/markers/ and open the NODEJS_VERSION file and add 0.12.2 at the bottom. My file looks like this:

 # Uncomment one of the version lines to select the node version to use. # The last "non-blank" version line is the one picked up by the code in # .openshift/lib/utils # Default: 0.10.25 # # 0.8.24 # 0.9.1 # 0.10.25 # 0.11.11 # 0.10.25 0.12.2 

Then upload the project via git to OpenShift (to the project root directory).

 git add -A . git commit -a -m "replaced .openshift directory" git push 

- the flag of harmony?

as specified in ECMAScript 6, available in Node.js 0.12 - the gamma flag is still needed for certain functions.

This means adding it to your package.json file , look at my question to see an example.

+1
source

All Articles