http.createServer(function (req, res) {Issue closed as no further information was provided
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");
TypeError: http.createServer is not a function
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:
const http =("http");requireis missing hereconst rstream = fs.creatReadStream("input.txt");creat -> create
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");
- Use Markdown, see my first paragraph
- This code still has those two errors