How do I make Openshift to use Express 4, instead of its installed Express 3?
express, node.js, openshift
Solution
Here's how to troubleshoot:
- ssh into your cartridge
- cd into the app-root/repo directory
- run `grep version ./node_modules/express/package.json`
- you should see a version based on your `package.json` dependency
- verify your package.json has a `scripts` section containing a `start` command that just runs your app with something like `node ./server.js` (server.js being whatever file you coded your main app start script in). You don't need the `express` command line program to launch an express server. It's for setting up new project boilerplate and other ancillary tasks.
- To see the version of express running within your app, you can add this code to your `server.js` (or equivalent) file: `console.log(require("express/package").version);`
Problem
I developed my Nodejs Express app locally using Express 4 and it works as expected on my computer. I then git the whole app up to Openshift. When I try to run it Openshift returns"503 Service Unavailable". If I ssh into my base Node cartridge and do "express -V" it returns version 3.2.5. I get the same version 3.2.5 if I go into my app folder at app-root/repo and run "express -V". So clearly my Express 4 which was included in the git upload in my app's node_modules is not being used. What is the solution to use Express 4 as required by my app? Ideas are- remove Openshift's version of Express 3, force Openshift to use my Express 4 in my app area, upgrade Openshift's Express 3 to Express 4. I cannot figure out how to do any of those and I have researched this.