background preloader

An Absolute Beginner's Guide to Node.js

An Absolute Beginner's Guide to Node.js
There's no shortage of Node.js tutorials out there, but most of them cover specific use cases or topics that only apply when you've already got Node up and running. I see comments every once and awhile that sound something like, "I've downloaded Node, now what?" This tutorial answers that question and explains how to get started from the very beginning. What is Node.js? A lot of the confusion for newcomers to Node is misunderstanding exactly what it is. An important thing to realize is that Node is not a webserver. Installing Node Node.js is very easy to install. I've Installed Node, now what? Once installed you'll have access to a new command called "node". $ node > console.log('Hello World'); Hello World undefined In the above example I typed "console.log('Hello World')" into the shell and hit enter. The other way to run Node is by providing it a JavaScript file to execute. hello.js console.log('Hello World'); $ node hello.js Hello World Doing Something Useful - File I/O example_log.txt

NoFlo: two years of flow-based programming - Henri Bergius in Berlin, Germany NoFlo — the flow-based programming system I started — is now two years old. I pushed the first commits to GitHub on June 5th 2011 from Hacker Dojo in Mountain View. To get us started with the story, I’ll let Wikipedia summarize: Flow-based programming (FBP) is a programming paradigm that defines applications as networks of “black box” processes, which exchange data across predefined connections by message passing, where the connections are specified externally to the processes. While flow-based programming is still far from mainstream, it has been great to watch to the community grow around NoFlo. There are several start-ups using it as their base infrastructure, with several of their engineers contributing to the open source effort. Why I started NoFlo Two years ago I was undergoing a transition from PHP and Python to the JavaScript world, largely lured by the benefits of a universal runtime and the event-based multi-protocol paradigm Node.js offers. Beyond OOP The logic is in the graph

A Case-by-Case Introduction to Node.js Introduction JavaScript’s rising popularity has brought with it a lot of changes, and the face of web development today is dramatically different. The things that we can do on the web nowadays with JavaScript running on the server, as well as in the browser, were hard to imagine just several years ago, or were encapsulated within sandboxed environments like Flash or Java Applets. Before digging into Node.js, you might want to read up on the benefits of using JavaScript across the stack which unifies the language and data format (JSON), allowing you to optimally reuse developer resources. As this is more a benefit of JavaScript than Node.js specifically, we won’t discuss it much here. But it’s a key advantage to incorporating Node in your stack. As Wikipedia states: “Node.js is a packaged compilation of Google’s V8 JavaScript engine, the libuv platform abstraction layer, and a core library, which is itself primarily written in JavaScript.” How Does It Work? That’s a mouthful. Pros: Cons:

Simple REST Service with Node.js and Express - QAT Global Introduction This is a simple tutorial showing how to create a REST service with Node.js using Express. This first tutorial will assume you have already installed Node.js, but it will walk you through installing Express and setting up a project. If you are unfamiliar with Node.js, please visit their official website. The code for this tutorial is available here on github. Setup The Environment If you don't already have express installed, you can install it with the following command: npm install express -g You will want to create a new directory for your project, so create your project directory and then from within that directory, run the following command to create your new project shell. express The express command generates a project using the jade template engine. npm install -d This command will download and install all of the dependencies into your project. node app.js Coding The Service Let's start by taking a look at the userProvider-array.js file: app. Testing The Service

How do I get started with Node.js Qu'est ce que NodeJS ? Actualité Web-Wave.fr - Web-Wave NodeJS est une plateforme construite sur le moteur JavaScript V8 de Chrome qui permet de développer des applications en utilisant du JavaScript. Il se distingue des autres plateformes grâce à une approche non bloquante permettant d’effectuer des entrées/sorties (I/O) de manière asynchrone. Pourquoi NodeJS ? Avant de commencer à découvrir une nouvelle technologie, il est important d’en comprendre les spécificités. Pour comprendre nous allons partir de la description donnée sur le site officiel : Node.js® is a JavaScript runtime built on Chrome’s V8 JavaScript engine. built on Chrome’s V8 JavaScript engine : Afin d’interpréter le code que l’on va écrire en JavaScript NodeJS se repose sur le moteur V8 qui équipe actuellement Chrome. Ce que n’est pas NodeJS NodeJS n’est pas un framework. Hello world Voici un exemple d’utilisation, comment faire un serveur http avec Node.js (exemple.js) Puis exécutez ce fichier avec la commande suivante :

Felix's Node.js Beginners Guide « Home / All Guides There is lots of information about node.js, but given the rapid pace at which it is developing, it can be difficult for beginners to find good, current information on how to get started. This guide aims to provide exactly that, whilst staying updated with the latest stable version of node.js. This guide has been updated to reflect the latest changes in node 0.4.x, the currently stable branch of node.js. Learning JavaScript This guide assumes that you are already familar with JavaScript. Hello World Tutorial This tutorial guides you through installing node.js, including the creation of a simple hello world http server. Installation First of all: You should run a *nix operating system in order to use node.js at this point. The most common way to install node.js is to directly compile it from the downloaded source code. You can get the latest source code from nodejs.org. $ wget $ tar -xzf node-v0.4.4.tar.gz $ cd node-v0.4.4 $ . Express

Understanding node.js Node.js has generally caused two reactions in people I've introduced it to. Basically people either "got it" right away, or they ended up being very confused. If you have been in the second group so far, here is my attempt to explain node: It is a command line tool. "But I can do everything I need in: ruby, python, php, java, ... !". I hear you. "Get to the point!" Alright, I will. "Huh?" That's right, everything runs in parallel, except your code. The day starts by one servant waking up the king and asking him if he needs anything. Once a servant finishes a task, he lines up outside the kings quarter to report. Life is good, for the king's servants carry out all of his tasks in parallel, but only report with one result at a time, so the king can focus "That's fantastic, but could you quit the silly metaphor and speak geek to me?" Sure. var fs = require('fs') , sys = require('sys'); fs.writeFile('letter-to-princess.txt', ' You got it! "Very nice, but why should I use it?" Yes and no. No. --fg

API Guide | restify restify is a node.js module built specifically to enable you to build correct REST web services. It intentionally borrows heavily from express as that is more or less the de facto API for writing web applications on top of node.js. Why use restify and not express? I get asked this more than anything else, so I'll just get it out of the way up front. Express' use case is targeted at browser applications and contains a lot of functionality, such as templating and rendering, to support that. Restify exists to let you build "strict" API services that are maintanable and observable. In short, I wrote restify as I needed a framework that gave me absolute control over interactions with HTTP and full observability into the latency and characteristics of my applications. About this guide This guide provides comprehensive documentation on writing a REST api (server) with restify, writing clients that easily consume REST APIs, and on the DTrace integration present in restify. Conventions Routing Events

The Node Beginner Book » A comprehensive Node.js tutorial Node.js Node.js is an open source, cross-platform runtime environment for server-side and networking applications. Node.js applications are written in JavaScript, and can be run within the Node.js runtime on OS X, Microsoft Windows, Linux, FreeBSD, NonStop and IBM i. Node.js provides an event-driven architecture and a non-blocking I/O API that optimizes an application's throughput and scalability. These technologies are commonly used for real-time web applications. Node.js is gaining adoption as a server-side platform[4] and is used by Microsoft,[5][6] Yahoo!,[7] Walmart,[8] Groupon,[9] SAP,[10] LinkedIn,[11][12] Rakuten, PayPal,[13][14] Voxer,[15] and GoDaddy.[16] History[edit] Ryan Dahl, creator of Node.js Node.js was invented in 2009 by Ryan Dahl, and other developers working at Joyent.[17] Node.js was created and first published for Linux use in 2009. Dahl was inspired to create Node.js after seeing a file upload progress bar on Flickr. In January 2014, Schlueter announced Timothy J. V8[edit]

How To Node - NodeJS Debugger Node.js v0.10.17 Manual Stability: 3 - Stable V8 comes with an extensive debugger which is accessible out-of-process via a simple TCP protocol. Node has a built-in client for this debugger. To use this, start Node with the debug argument; a prompt will appear: % node debug myscript.js < debugger listening on port 5858 connecting... ok break in /home/indutny/Code/git/indutny/myscript.js:1 1 x = 5; 2 setTimeout(function () { 3 debugger; debug> Node's debugger client doesn't support the full range of commands, but simple step and inspection is possible. For example, suppose myscript.js looked like this: x = 5;setTimeout(function () { debugger; console.log("world");}, 1000); console.log("hello"); Then once the debugger is run, it will break on line 4. The repl command allows you to evaluate code remotely. Watchers# You can watch expression and variable values while debugging your code. To start watching an expression, type watch("my_expression"). watchers prints the active watchers. Commands reference# Stepping# % . Info#

Related: