Has anyone done a Phonegap app based on a nodeJS app with node modules that are used in the code ?
Explanation: I have my node web app that work well on my computer, with an app.js that contains all the server code (require, server.listen on port 3000, the /public folder that is set up to be the root of the app etc...) and it doesn't seem to find the node_modules.
My app doesn't respect the file tree with the index.html at the root of the phonegap www folder and uses some node_modules.
Do not hesitate to ask further questions if you do not fully understand my question.
Thank you in advance phonegapers !!
Explanation: I have my node web app that work well on my computer, with an app.js that contains all the server code (require, server.listen on port 3000, the /public folder that is set up to be the root of the app etc...) and it doesn't seem to find the node_modules.
My app doesn't respect the file tree with the index.html at the root of the phonegap www folder and uses some node_modules.
Do not hesitate to ask further questions if you do not fully understand my question.
Thank you in advance phonegapers !!
- 6 Posts
- 0 Reply Likes
Posted 4 years ago
Petra V., Champion
- 7794 Posts
- 1391 Reply Likes
Not quite sure what you are trying to do.
nodeJS is a server-side scripting environment, as far as I know. What should it do in a Phonegap-built hybrid app?
nodeJS is a server-side scripting environment, as far as I know. What should it do in a Phonegap-built hybrid app?
- 6 Posts
- 0 Reply Likes
I have my web code (html, css and js) that I am trying to run inside phonegap and the way I run it my computer is with the "grunt serve" command. Inside this js file (server.js), there are these lines:
var express = require('express');
var path = require("path");
var fs = require('fs');
var app = express();
They use the dependencies inside the node_module folder and I need my web code to have access to this folder.
I basically need to serve the files in phonegap the way I serve them on my computer based on the serve configuration that is inside my server.js file
(Sorry if this doesn't make sense to you, but I'm pretty new to the nodeJS environnement...)
var express = require('express');
var path = require("path");
var fs = require('fs');
var app = express();
They use the dependencies inside the node_module folder and I need my web code to have access to this folder.
I basically need to serve the files in phonegap the way I serve them on my computer based on the serve configuration that is inside my server.js file
(Sorry if this doesn't make sense to you, but I'm pretty new to the nodeJS environnement...)
Petra V., Champion
- 7794 Posts
- 1391 Reply Likes
If I understand correctly, you run a server on your PC, which contains the NodeJS installation. The lines you showed are in a server configuration file.
The node_module folder is on that server too, right?
Typically, if a Phonegap-built hybrid app needs server functionality, an ajax request is made to a web service, which performs the functionality (like back end logic, database access, etc) and returns data to the calling app. In such environment, it makes no difference whether the server is java based, .net based, nodeJS based or otherwise.
The node_module folder is on that server too, right?
I basically need to serve the files in phonegapSorry, but to me, this makes no sense. You don't "serve something in Phonegap", because Phonegap is merely a build tool to create a hybrid app using client-side assets. At app execution time, Phonegap does absolutely nothing (albeit there is a cordova client-side javascript file which allows you to access plugin code, also present in the client app).
Typically, if a Phonegap-built hybrid app needs server functionality, an ajax request is made to a web service, which performs the functionality (like back end logic, database access, etc) and returns data to the calling app. In such environment, it makes no difference whether the server is java based, .net based, nodeJS based or otherwise.
- 6 Posts
- 0 Reply Likes
In my web app, all the files are located inside the /public folder and it is set up as the root. Every paths that I use in my html files are written considering that /public is the root. This is done in the server.js file that I execute with "grunt serve" :
This is the hierarchy of my project (currently):
Inside the www/ folder, I copy pasted my entire code without making any adjustments.
How can I indicate that my root is /public ? Because the code uses also files from the other folders (/proxy...)
This is the hierarchy of my project (currently):
Inside the www/ folder, I copy pasted my entire code without making any adjustments.
How can I indicate that my root is /public ? Because the code uses also files from the other folders (/proxy...)
- 6 Posts
- 0 Reply Likes
My index.html file is somewhere inside the /public/uaf/... folder
Petra V., Champion
- 7794 Posts
- 1391 Reply Likes
No, no....
An app, built using Phonegap, is part of a client server application. It is the client part!
Your input for Phonegap Build will be a zip file, which contains config.xml and index.html in the root directory, and other assets wherever you please. However, there will be no Cordova project specific directories, like /hooks, /platforms and /plugins. Also, you can't include stuff like androidManifest.xml or info.plist.
Now, the NodeJS parts are on your server. In a MVS architecture, your app is the View only.
An app, built using Phonegap, is part of a client server application. It is the client part!
Your input for Phonegap Build will be a zip file, which contains config.xml and index.html in the root directory, and other assets wherever you please. However, there will be no Cordova project specific directories, like /hooks, /platforms and /plugins. Also, you can't include stuff like androidManifest.xml or info.plist.
Now, the NodeJS parts are on your server. In a MVS architecture, your app is the View only.
How can I indicate that my root is /publicIn Phonegap Build, you can't. The root directory of the zip file is the root directory ("/"), nothing else. That has nothing to do with the directory on the server that contains your NodeJS installation.
- 6 Posts
- 0 Reply Likes
Thanks petra, I'm currently learning a bit more about the architecture of a nodeJS app and I'm starting to see what you mean.
thanks for your help !
thanks for your help !
JesseMonroy650 (Volunteer), Champion
- 3325 Posts
- 122 Reply Likes
@Simon,
this FAQ might help. It's due for a rewrite, but all issues still apply.
Top Mistakes by Developers new to Cordova/Phonegap
Best of Luck
Jesse
this FAQ might help. It's due for a rewrite, but all issues still apply.
Top Mistakes by Developers new to Cordova/Phonegap
Best of Luck
Jesse
- 6 Posts
- 0 Reply Likes
Thank you very much Jesse I'll look into it.
Related Categories
-
Programming (Others)
- 1167 Conversations
- 23 Followers


