I'm trying to write a simple file web file server. I'm using PhpStorm.
var http = require('http');
var fs = require('fs');
function send404Request(response) {
response.writeHead("404", {"Content-Type": "text/html"});
response.write("404 Page Not Found");
response.end();
}
function onRequest(request, response) {
if (request.method === 'GET' && request.url === '/') {
response.writeHead("200", {"Content-Type": "text/plain"});
fs.createReadStream("./index.html").pipe(response);
} else {
send404Request(response);
}
}
http.createServer(onRequest).listen(8888);
console.log("file server is now running...");
However, PhpStorm says "unresolved function or method pipe()"
Here is my setting for JavaScript libraries in PhpStorm:
Any idea where goes wrong?
In Settings/Project Settings/JavaScript/Libraries, Download "node-DefinitelyTyped". This work for me. I had the same issue as your.