Click here to Skip to main content
15,896,726 members
Please Sign up or sign in to vote.
2.00/5 (1 vote)
JavaScript
var http = require('http');
var fs = require('fs');

http.createServer(function(req, res){
    fs.readFile('1.html',function (err, data){
        res.writeHead(200, {'Content-Type': 'text/html','Content-Length':data.length});
        res.write(data);
        res.end();
    });
}).listen(8000);


What I have tried:

This js is not working. when i try to run through road it shows :-
module.js:327
throw err;
^
node version v4.4.3

my need is to open a html file stored in my pc
Posted
Updated 9-Jun-16 1:31am
v3
Comments
Mehdi Gholam 10-Jun-16 1:24am    
Try upgrading to the newer version of node.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900