Narcis Posted March 18, 2020 Share Posted March 18, 2020 I try to learn Node.js. I followed that tutorial: https://www.w3schools.com/nodejs/nodejs_get_started.asp As the tutorial says, I created a file: myfirst.js with that content: var http = require('http'); http.createServer(function (req, res) { res.writeHead(200, {'Content-Type': 'text/html'}); res.end('Hello World!'); }).listen(8080); I have a Mac. I open the Terminal and reach that file: Your Name>node myfirst.js I open a browser and type the address: http://localhost:8080 And I see nothing. Safari says: Safari can't connect to the Server. Similar with other browsers. What is wrong? Link to comment Share on other sites More sharing options...
Funce Posted March 18, 2020 Share Posted March 18, 2020 Did node say anything after that? Any errors? Did you keep the terminal open? Node runs as a process inside that, so if you close it, no more server. Link to comment Share on other sites More sharing options...
Narcis Posted March 19, 2020 Author Share Posted March 19, 2020 I still do not understand very well that concept of server and "Node running as a process inside the terminal". But thank you, now I can continue and perhaps I will have a more clear idea when I finish the tutorial? Link to comment Share on other sites More sharing options...
Funce Posted March 19, 2020 Share Posted March 19, 2020 You might do, although you may want to look up terms you're unfamiliar with. If you have any further questions about it, you're always free to ask here. Link to comment Share on other sites More sharing options...
Narcis Posted March 20, 2020 Author Share Posted March 20, 2020 Great. This really helps! Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now