Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

http.createServer(function (req, res) {Issue closed as no further information was provided #20

Open
kyela999 opened this issue May 12, 2021 · 4 comments

Comments

@kyela999
Copy link

kyela999 commented May 12, 2021

Issue is TypeError: http.createServer is not a function

_Originally posted by @nic11 in #14 (comment)
_const fs = require("fs");
const http =("http");
const server = http.createServer();
server.on('request', (req, res) => {
const rstream = fs.creatReadStream("input.txt");
rstream.on("data", (chunkdata) => {
res.write(chunkdata);
});
rstream.on("end", () =>{
});
rstream.on('error', (err) => {
console.log(err);
res.end("file is not found");
});
});
server.listen(8000,"127.0.0.1");

@kyela999
Copy link
Author

TypeError: http.createServer is not a function

@nic11
Copy link
Member

nic11 commented May 12, 2021

First of all, please use Markdown to properly format code snippet. E.g., see examples -> code here: https://guides.github.com/features/mastering-markdown/

Or fenced code blocks here: https://guides.github.com/pdfs/markdown-cheatsheet-online.pdf

I can see at least two typos:

  1. const http =("http");
    require is missing here
  2. const rstream = fs.creatReadStream("input.txt");
    creat -> create

@kyela999
Copy link
Author

internal/modules/cjs/loader.js:883
throw err;
Error: Cannot find module '/home/rinku/nodedex/index.js' in this code after corect this error show

_const fs = require("fs");
const http =("http");
const rstream =
fs.creatReadStream("input.txt");
const server = http.createServer();
server.on('request', (req, res) => {

rstream.on("data", (chunkdata) => {
res.write(chunkdata);
});
rstream.on("end", () =>{
});
rstream.on('error', (err) => {
console.log(err);
res.end("file is not found");
});
});
server.listen(8000,"127.0.0.1");

@nic11
Copy link
Member

nic11 commented May 15, 2021

  1. Use Markdown, see my first paragraph
  2. This code still has those two errors

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants