Use edge js on openshift - node.js

I'm trying to run C# on my OpenShift cartridge with Edge.js. It runs really good on my Windows PC and I would like to have it running on the cloud.
I'm guessing it runs on a Linux environment but I'm not shure.
At first I tried to make it work with my MSSQL DB and than move on to the C# assembly.
Nevertheless I'm doing the same steps as how I've got it to work on my Windows machine but I'm getting thesame errors over and over again.
I've added edge and edge-sql to my npm and my package.json.
Then I've make a simple count to my MSSQL DB.
When I'm running it locally it works great. Than I push it to OpenShift and I tail the application, because the front-end gives me an Error 503, and the next thing I know the following error makes me keepings my hands in my hair.
Error: The edge native module is not available at /var/lib/openshift/54d26260fcf
933d05e00021a/app-root/runtime/repo/node_modules/edge/build/Release/edge.node. Y
ou can use EDGE_NATIVE environment variable to provide alternate location of edg
e.node. If you need to build edge.node, follow build instructions for your platf
orm at https://github.com/tjanczuk/edge
at Object.<anonymous> (/var/lib/openshift/54d26260fcf933d05e00021a/app-root/
runtime/repo/node_modules/edge/lib/edge.js:33:11)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Module.require (module.js:364:17)
at require (module.js:380:17)
at Object.<anonymous> (/var/lib/openshift/54d26260fcf933d05e00021a/app-root/
runtime/repo/server.js:5:12)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
DEBUG: Program node server.js exited with code 8
DEBUG: Starting child process with 'node server.js'
/var/lib/openshift/54d26260fcf933d05e00021a/app-root/runtime/repo/node_modules/e
dge/lib/edge.js:33
throw new Error('The edge native module is not available at ' + builtEdge
Could somebody help me to fix this error or maybe explain to me why it could / wont work?

If edge requires a native windows environment to run C#, then it will not work on OpenShift, which runs on Red Hat Linux.

Related

NextJS build error - ReferenceError: navigator is not defined

I'm running into this special error message while trying to build a simple NextJS application (using npm run build):
> Build error occurred
ReferenceError: navigator is not defined
at /cdk-next/next-frontend/node_modules/codemirror/lib/codemirror.js:18:19
at /cdk-next/next-frontend/node_modules/codemirror/lib/codemirror.js:11:83
at Object.<anonymous> (/cdk-next/next-frontend/node_modules/codemirror/lib/codemirror.js:14:2)
at Module._compile (node:internal/modules/cjs/loader:1101:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10)
at Module.load (node:internal/modules/cjs/loader:981:32)
at Function.Module._load (node:internal/modules/cjs/loader:822:12)
at Module.require (node:internal/modules/cjs/loader:1005:19)
at require (node:internal/modules/cjs/helpers:102:18)
at Object.<anonymous> (/cdk-next/next-frontend/node_modules/easymde/src/js/easymde.js:2:18) {
type: 'ReferenceError'
}
info - Collecting page data .
I don't know who codemirror is, or why it's not letting me build my project. From reading around I gather that this issue occurs with NextJS when trying to build a project on the server side instead of the client side, because the project does not have access to a window or navigator. In that case, what should I do? The tutorial I'm following seems to breeze through this step just fine, so should I just look at their package.json and downgrade all of my packages? Any advice would be appreciated.
The error was with my import of import SimpleMDE from "react-simplemde-editor" (located in create-post.js of the repo link above).
I implemented the solution proposed by modikum here: https://github.com/dabit3/next.js-amplify-workshop/issues/21.
Now the project builds successfully.

ReferenceError: window is not defined in godash

I am trying to build a board game and want to use godash to create a board state and update it. I have successfully installed godash into my package.json, but when I require it in the back-end, in my server.js (the file in which I run my server),
var godash = require ('godash');
and I run node server.js, the CLI responds with this error:
ReferenceError: window is not defined
at Object.<anonymous> (C:\Users\Chidi\gt\projects\Chess-vs-Go\node_modules\godash\dist\godash.js:1:194)
at Module._compile (internal/modules/cjs/loader.js:1063:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1092:10)
at Module.load (internal/modules/cjs/loader.js:928:32)
at Function.Module._load (internal/modules/cjs/loader.js:769:14)
at Module.require (internal/modules/cjs/loader.js:952:19)
at require (internal/modules/cjs/helpers.js:88:18)
at Object.<anonymous> (C:\Users\Chidi\gt\projects\Chess-vs-Go\game_state\go_state.js:2:14)
at Module._compile (internal/modules/cjs/loader.js:1063:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1092:10)
I've seen various "window is not defined" questions on this site in my effort to solve this problem, and the general solution seems to be that the code should be used in a browser environment. However, this is godash, an npm package that is to be used in the back-end. I have tried updating node.js and npm to their latest versions, but the problem still persists. I feel like I am making an obvious error that I can't see, because I went to the github page for godash and did not find any closed or open issues similar to this one. Does anyone know what the issue is, and how I can resolve it?
So, upon further research, I found that there are ways to use npm packages in the browser (e.g via browserify) This allowed me to use godash in the browser, where it was looking for a window object.

Node JS app on OpenShift gives error 503

So I created a NodeJS app for a college project which monitors page loading speed. In order to record said speed I need people to go to the web application, go to a certain page and hit a button a couple of times.
So I looked up a way to host this app, free of charge, and came up with OpenShift.
After figuring out how it all worked I managed to setup an OpenShift git-repository and I am able to push my changes to the server.
However upon visiting my page I kept getting error 503. Initially I thought it was a node modules error so I found npm shrinkwrap which solved npm version issues. The error, is still around.
When I run the app locally, I get no errors whatsoever and all modules are installed correctly. They are also in a package.json file (I used npm install --save for all my modules, so no manual editing was performed).
These are the first couple of lines from using the tail-command and whopping the result into a text file.
==> app-root/logs/nodejs.log <==
at Connection.connect (/var/lib/openshift/550db5624382ecf8f400000f/app>root/runtime/repo/node_modules/mysql/lib/Connection.js:109:18)
at Object.<anonymous> (/var/lib/openshift/550db5624382ecf8f400000f/approot/runtime/repo/server.js:28:12)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Function.Module.runMain (module.js:497:10)
at startup (node.js:119:16)
DEBUG: Program node server.js exited with code 8
DEBUG: Starting child process with 'node server.js'
I also found this:
==> app-root/logs/nodejs.log <==
Error: connect ECONNREFUSED
at errnoException (net.js:901:11)
at Object.afterConnect [as oncomplete] (net.js:892:19)
--------------------
at Protocol._enqueue (/var/lib/openshift/550db5624382ecf8f400000f/app-root/runtime/repo/node_modules/mysql/lib/protocol/Protocol.js:135:48)
at Protocol.handshake (/var/lib/openshift/550db5624382ecf8f400000f/app-root/runtime/repo/node_modules/mysql/lib/protocol/Protocol.js:52:41)
at Connection.connect (/var/lib/openshift/550db5624382ecf8f400000f/app-root/runtime/repo/node_modules/mysql/lib/Connection.js:109:18)
at Object.<anonymous> (/var/lib/openshift/550db5624382ecf8f400000f/app-root/runtime/repo/server.js:28:12)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Function.Module.runMain (module.js:497:10)
at startup (node.js:119:16)
DEBUG: Program node server.js exited with code 8
Any idea's?
Mine did the same when I first pushed to OpenShift. I think I had to review some references and make some slight changes. My log on OpenShift indicated that such-and-such file couldn't be found. Yours might, too, if you review the entire thing.
For example, this is the "after" version of something I edited:
self.app.set('views', path.join(__dirname, 'views'));
I might have had just this before:
self.app.set('views', '/views');
Hope that helps.
Well... you've got...
Error: connect ECONNREFUSED
...which suggests that Express couldn't connect to the database. Maybe you've got dev versus prod credentials going on and the code's trying to use the local credentials, the local database name, the local username, the local server, etc.
I'm using MongoDB (no credentials locally) and have created a /db.js file to store all that. And then my /server.js selects which variable:
if (typeof process.env.OPENSHIFT_NODEJS_IP === "undefined") { mongoose.connect(dbConfig.devurl); } else { mongoose.connect(dbConfig.produrl); }
Note the two different variables after dbConfig.varname.

How to use node-oracle with iisnode?

I'm having trouble trying to run a Node.js server with node-oracle via iisnode. The iisnode examples all work, and running the server [on a different port] in a Command Window works perfectly. The server setup is based upon "The Node Beginner Book" example (i.e. index.njs -> server.njs -> router.njs -> requesthandlers.njs). I renamed all of my node files as *.njs and currently have my web.config set up for iisnode to handle all files of that extension, with a rewrite rule to forward the incoming requests to index.njs. The problem occurs when node-oracle -- utilized within requesthandlers.njs -- attempts to call oracle_bindings.node:
Application has thrown an uncaught exception and is terminated:
Error: The specified module could not be found.
c:\Program Files\iisnode\www\Reports\node_modules\oracle\build\Release\oracle_bindings.node
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Module.require (module.js:364:17)
at require (module.js:380:17)
at Object.<anonymous> (c:\Program Files\iisnode\www\Reports\node_modules\oracle\lib\oracle.njs:2:16)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Module.require (module.js:364:17)
I've given read/write/execute permissions to the IIS_IUSRS group on every folder imaginable within the .\iisnode\www\Reports\node_modules\oracle path. I've also attempted the solution in Node cannot find modules in IIS, can find from prompt to no avail. While I could probably just set the server up as a service, I'd prefer to have it through IIS so that I don't have to battle with CORS while supporting IE9. Any help is greatly appreciated, thanks!

Node.js - Module Version Mismatch on Linode Server

I am trying to deploy a node app on Linode (Ubuntu 12.04) while following this guide from Node Knockout: http://blog.nodeknockout.com/post/9300619913/countdown-to-ko-14-deploying-your-node-js-app-to
I have no problems running the server as root, but when trying to start the server as the "deploy" user using sudo start node, I get this error:
/home/deploy/app/source/node_modules/bcrypt/node_modules/bindings/bindings.js:79
throw e
^
Error: Module version mismatch. Expected 11, got 1.
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Module.require (module.js:364:17)
at require (module.js:380:17)
at bindings (/home/deploy/app/source/node_modules/bcrypt/node_modules/bindings/$
at Object.<anonymous> (/home/deploy/app/source/node_modules/bcrypt/bcrypt.js:1:$
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
I have tried recompiling bcrypt using make clean then make since I thought my module version was incompatible with my version of node (v0.8.18), but that does not seem to be the case since I can start the server as root with no problem. I feel as though the problem lies in how I set up the deploy user, but I am not sure how to proceed.

Resources