Stò uscendo pazzo!!
Tante guide online ma mi sfugge qualcosa che mi fa entrare nella "logica" di sviluppo di NodeJs.
Installato NodeJs e tramite console ricevo il seguente messaggio:
> console
Console {
log: [Function: bound ],
info: [Function: bound ],
warn: [Function: bound ],
error: [Function: bound ],
dir: [Function: bound ],
time: [Function: bound ],
timeEnd: [Function: bound ],
trace: [Function: bound trace],
assert: [Function: bound ],
Console: [Function: Console] }
>
L'installazione è corretta?
Poi creao un file js (che non so esattamente dove metterlo) del tipo:
var http = require("http") ;
function onRequest(request, response) {
console.log("Server - onRequest") ;
response.writeHead(200, {"Content-Type": "text/plain"}) ;
response.write("Ciao Mondo!") ;
response.end() ;
}
http.createServer(onRequest).listen(8080) ;
console.log("Server is up and running") ;
E fino a qui tutto ok.
Poi immagino che devo puntare tramite console al file js creato ma non so come fare. I files vanno messi in una directory particolare?
Faccio:
> path.dirname
e mi restituisce solo:
[Function]
[/COLOR][/COLOR]
Dove sbaglio? (oltre, probabilmente a ripetere sempre lo stesso errore?)
Grazie