Are there any good resources to get started with Node.JS? Any good tutorials, blogs or books?
Of course, I have visited its official website http://nodejs.org/, but I didn't think the documentation they have is a good starting point.
Are there any good resources to get started with Node.JS? Any good tutorials, blogs or books?
Of course, I have visited its official website http://nodejs.org/, but I didn't think the documentation they have is a good starting point.
Here is how you can start in 10 minutes or less. (Windows)
1 - 3 minutes : download and install your flavor.
4 - 5 minutes : open command prompt assuming your installation is on windows and on c drive. cd to the nodejs directory
C:\>cd nodejs
hit enter and then type
C:\nodejs>node
>
let's exit for a moment by pressing ctrl + c twice to go back to nodejs directory.
6 - 10 minutes : create a new file test.js in C:\nodejs\test.js. Copy and paste codes below and save your changes.
console.log("Welcome to my first NodeJs Program");
go back to your terminal and type
C:\nodejs>node test.js
hit enter and you should get something like this
C:\nodejs>node test.js
Welcome to my first NodeJs Program
In addition to cereal's recommendation read this great tutorial. Read the Doing Something Useful - HTTP Server paragraph.
Once you have immersed with the syntax, try reading Doing Something Useful - Express it is about the express framework. Make sure to always follow these simple protocols and you won't get lost.
Practice and read Pro Node.Js for Developers from Appress written by Colin J Ihrig, Andy Ihrig.
I want to add
if you follow the tutorial, You need to change the port number
var http = require('http');
http.createServer(function (req, res) {
res.writeHead(200, {'Content-Type': 'text/plain'});
res.end('Hello World\n');
}).listen(8080);
console.log('Server running on port 8080.');
Just change the 8080 to something different to prevent any conflict with WAMP, XAMPP, UNIZero and others.
test on port 9999, then type on your browser http://localhost:9999. By setting it up like this you can still use the http://localhost/ for your PHP server.
This is how I set my development servers Apache port 80; Nodjs port 92; Python port 95
First, you must intall Node.js. After that, you create a new JS file, and put this in it...
var app = require('express')();
var http = require('http').Server(app);
app.get('/', function(req, res) {
res.sendFile(__dirname + '/chat.html');
});
http.listen(3000, function() {
console.log("Loaded!");
});
Then, you must create an HTML file to be displayed.
<html>
<head>
<title>Views</title>
</head>
<style>
#msgs {list-style-type: none; background: #99CCFF}
</style>
<body>
<center>
<ul id="msgs"></ul>
</center>
</body>
</html>
Once you have done that, you are all set to run it. To run it, you must open your command prompt, then go to the directory where you stored the JS file. After this, you must type in your command line, "node YOURFILENAME.js"
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.