-4

With my current web development practices, I always run my code (html, css, javascript) on an internet browser. I'm trying to learn Node.js, and all the tutorials are using command line to run the node.js files. My problem is, I don't know how to use terminal for development purposes (I've never really used it at all) Why would I even be running a website on a terminal window rather than a browser where it should be run? And lastly, can I run node.js code on a web browser, similar to how I run my javascript files? Or do i HAVE TO run Node.js on a terminal window if I want to test it or something?

Limon Monte
  • 52,539
  • 45
  • 182
  • 213
user3646493
  • 53
  • 1
  • 7
  • http://en.wikipedia.org/wiki/Node.js – zerkms Apr 24 '15 at 00:08
  • 1
    I think you are misunderstanding what Node.js is. Node.js, just like the browser, is an environment to execute JavaScript. However, the browser does much more than just executing JS, it renders HTML pages. – Felix Kling Apr 24 '15 at 00:08
  • node is your server framework is why – charlietfl Apr 24 '15 at 00:11
  • Not all computer programs are GUI-based. In particular, web servers. Why would a web server have a GUI? It's job is to listen on net sockets and respond on net sockets. Nothing graphical about it. If you haven't learned how to use a command line, then you haven't learned how to use a computer. – Lee Daniel Crocker Apr 24 '15 at 00:24

1 Answers1

0

This content shows 3 basic steps:

Step 1 Install Node.js

Step 2 Use an editor to write some JavaScript

Step 3 Run the application "node appName.js" and a browser to test "host-ip:port" ex: http://127.0.0.1:3000

source code

var http = require('http');
http.createServer(function (req, res) {
    res.writeHead(200, { 'Content-Type': 'text/plain' });
    res.end('Hello World\n');
}).listen(3000, "127.0.0.1");
console.log('Server running at http://127.0.0.1:3000/');
Rahaman
  • 323
  • 1
  • 9