Launch application with nodejs
-
Hi,
I want to test an application on Debian VirtualMachine with nodejs installed.
My friend dev give me this code to run on my VM
Folder Root
Client Folder
Server Folder
Vendor Folder
I don't know hox to launch code.
I tried to do " node httpserver.js" for launch the game but when i go on http://ipserver/httpserver.js i can't load the page.Can you explain how node works please
Regards
-
You start a node application from within the directory that holds the package.json ("Folder Root").
You can runnode .
(optionally followed with program arguments) in there.
What that application does is defined by the application itself, I doubt it would provide its own source code as you're trying to access it.
Ask your friend how to communicate with the running application. Since it seems to be a server it's most likely listening to any port likehttp://ip-of-server:8128
.
A well-written server should output such information on startup. -
Don't work but it's on the root on my apache2
-
@Rémy-Verger It's not
node package.json
butnode path/to/the/application/
, so if you're already within the directory you can give it a.
as path (.
= current directory).
node .
ornode ./
ornode /var/www/
, those are equivalent. -
Oh !
Thanks dude but it's don't work.
Library probblem ? Or code error ? -
Does it work if you call
npm install
within /var/www first (I assume you havenpm
installed)? I just noticed you haven't done that yet, it installs dependencies for that project. -
@julian Did you mean
node package.json
? I don't see any server.json. Yes, I am sure. Calling the package.json with node will not start any application, It would (probably; I have no way proving this) interpret the JSON content alikerequire("./package.json")
but won't start themain
file. -
@julian server is a directory (see OP) it could be server/httpServer.js thought, but the package.json should specify the entry point anyways; Thus
node .
within the directory containing package.json is always best. -
Oh thanks i didn"t install npm
But now when i did "npm start" and i want to execute the code i got this errorty guys BTW
-
@Rémy-Verger run
npm start
from/var/www
-
@Rémy-Verger What program is this anyway? Perhaps you're better off asking them directly for help