node-twitch-webhook icon indicating copy to clipboard operation
node-twitch-webhook copied to clipboard

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

Open kyela999 opened this issue 4 years ago • 4 comments

Issue is TypeError: http.createServer is not a function

_Originally posted by @nic11 in https://github.com/true-dubach/node-twitch-webhook/issues/14#issuecomment-496205248 _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 avatar May 12 '21 17:05 kyela999

TypeError: http.createServer is not a function

kyela999 avatar May 12 '21 17:05 kyela999

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

nic11 avatar May 12 '21 23:05 nic11

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");

kyela999 avatar May 13 '21 09:05 kyela999

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

nic11 avatar May 15 '21 03:05 nic11