'my nodemon module is not working with node js
Basically, ive got start:"nodemon node.js" node.js is the actual file. but all it does is bring it up in my editor and port 3000 still isnt responding like it would if i typed node node.js every time i edited it. i did everything in the tutorial verbatim looked up the actual docs and searched stack and im still at a stand still, i am new to this and could use some help please,i installed it npm install nodemon --save-dev and would like to be able to do this in the local environment if possible, the modules are there, its just alot to past here, thanks in advance heres my code and such... edit: when i run it i get
[email protected] start nodemon node.js in the terminal
const http = require('http');
const fs = require('fs');
const server = http.createServer((req,resp)=>{
const url = req.url;
const method = req.method;
{
"name": "nod",
"version": "1.0.0",
"description": "",
"main": "node.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"start": "nodemon node.js"
},
"author": "",
"license": "ISC",
"devDependencies": {
"nodemon": "^2.0.15"
}
}
//.........................................................................................
if(url === '/'){
resp.write('<html>');
resp.write('<head><title>first</title></head>')
resp.write('<body>');
resp.write('<form action="/message"npmns npmno method="POST"><input type="text" name="message"><button type="submit">subn</button></form>');
resp.write('</body>');
resp.write('</html');
return resp.end();
}
if(url === '/message' && method=== 'POST'){
// resp.write('<html>');
// resp.write('<body');
const body =[];
req.on('data',(chunk)=>{
body.push(chunk);
})
req.on('end',(data)=> {
let message = body.toString().split('=')[1];
fs.writeFileSync('billy.txt', message);
})
resp.write('<form action="/" method="POST"><button type="submit">butt</button></form>');
// resp.write('</body>');
// resp.write('</html>');
return resp.end();
}
resp.setHeader('content-type','text/html');
resp.write('<html>');
resp.write('<head><title>firsttime</title></head>');
resp.write('<body><h1>hello again</h1></body>');
resp.write('</html>');
resp.end();
})
server.listen(3000);
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
