Questions tagged [node.js]

Node.js is an event-based, non-blocking, asynchronous I/O runtime that uses Google's V8 JavaScript engine and libuv library. It is used for developing applications that make heavy use of the ability to run JavaScript both on the client as well as on the server side and therefore benefit from the re-usability of code and the lack of context switching.

Node.js is an event-based, non-blocking, asynchronous I/O (input/output) runtime that uses Google's V8 JavaScript Engine.

, commonly just called Node, is often used for developing applications that rely on the ability to run both on the client and server side. Running the same language on both the client and the server benefits from improved code reusability and less context switching.

A notable feature of is that it is non-blocking – if one task stalls or pauses for an I/O operation, another can take over while idle. This allows for high efficiency as the program as a whole never has to idle and wait for one task to finish. Libraries such as async take advantage of this capability. More information can be found here.

It's also possible to use mature JavaScript frameworks like YUI and jQuery for server-side DOM manipulation in .

To ease the development of complex JavaScript further, Node.js supports the CommonJS standard that allows for modularized development and the distribution of software in packages via the Node Package Manager (NPM).

Download node.js:

Applications that can be written using Node.js include, but are not limited to:

  • Static file servers
  • Web Application frameworks
  • Messaging middleware
  • Servers for HTML5 multi player games, or streaming audio/video
  • Real time applications
  • Cross-platform programs

When asking questions about Node.js, you should:

  1. Make sure to check the official API documentation before asking, your question might be trivial.
  2. Isolate the problem and reproduce it with as little code as possible.
  3. If the question has nothing to do with anything that's specific, please consider asking it as a question instead.
  4. Mention which version of Node.js you are running. When in doubt, use node -v or node --version.
  5. Make sure to only use the tag, since is ambiguous.

Interesting Questions and Answers

Useful Links

Tutorials, Guides and Books

Talks, Presentations, and Podcasts on Node.js

Free Node.js Books and Resources

Chat Room & Mailing list

Logging

  • pino - Extremely fast logger inspired by Bunyan.
  • winston - Multi-transport async logging library.
  • console-log-level - The most simple logger imaginable with support for - log levels and custom prefixes.
  • storyboard - End-to-end, hierarchical, real-time, colorful logs and stories.
  • signale - Hackable console logger with beautiful output.

Official logo

Official logo

Node.js is copyrighted by the openJS Foundation

466830 questions
1262
votes
3 answers

How do I get started with Node.js

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.
Joneph O.
  • 6,887
  • 5
  • 20
  • 9
1212
votes
28 answers

In Node.js, how do I "include" functions from my other files?

Let's say I have a file called app.js. Pretty simple: var express = require('express'); var app = express.createServer(); app.set('views', __dirname + '/views'); app.set('view engine', 'ejs'); app.get('/', function(req, res){ res.render('index',…
TIMEX
  • 259,804
  • 351
  • 777
  • 1,080
1209
votes
8 answers

How can I do Base64 encoding in Node.js?

Does Node.js have built-in Base64 encoding yet? The reason why I ask this is that final() from crypto can only output hexadecimal, binary or ASCII data. For example: var cipher = crypto.createCipheriv('des-ede3-cbc', encryption_key, iv); var ciph =…
murvinlai
  • 48,919
  • 52
  • 129
  • 177
1209
votes
18 answers

What is the difference between --save and --save-dev?

What is the difference between: npm install [package_name] and: npm install [package_name] --save and: npm install [package_name] --save-dev What does this mean? And what is really the effect of --save and -dev keywords?
nfort
  • 12,234
  • 3
  • 13
  • 13
1184
votes
10 answers

How to install a previous exact version of a NPM package?

I used nvm to download node v0.4.10 and installed npm to work with that version of node. I am trying to install express using npm install express -g and I get an error that express requires node version >= 0.5.0. Well, this is odd, since I am…
stewart99
  • 14,024
  • 7
  • 27
  • 42
1176
votes
47 answers

Error: Can't set headers after they are sent to the client

I'm fairly new to Node.js and I am having some issues. I am using Node.js 4.10 and Express 2.4.3. When I try to access http://127.0.0.1:8888/auth/facebook, i'll be redirected to http://127.0.0.1:8888/auth/facebook_callback. I then received the…
DjangoRocks
  • 13,598
  • 7
  • 37
  • 52
1135
votes
12 answers

Node.js + Nginx - What now?

I've set up Node.js and Nginx on my server. Now I want to use it, but, before I start there are 2 questions: How should they work together? How should I handle the requests? There are 2 concepts for a Node.js server, which one is better: a.…
Van Coding
  • 24,244
  • 24
  • 88
  • 132
1128
votes
24 answers

How is an HTTP POST request made in node.js?

How can I make an outbound HTTP POST request, with data, in node.js?
Mark
  • 67,098
  • 47
  • 117
  • 162
1128
votes
24 answers

How to create a directory if it doesn't exist using Node.js

Is the following the right way to create a directory if it doesn't exist? It should have full permission for the script and readable by others. var dir = __dirname + '/upload'; if (!path.existsSync(dir)) { fs.mkdirSync(dir, 0744); }
Whisher
  • 31,320
  • 32
  • 120
  • 201
1070
votes
37 answers

Upgrading Node.js to latest version

So, I have Node.js installed and now when I tried to install Mongoosejs I got an error telling me that I don't have the needed version of Node.js (I have v0.4.11 and v0.4.12 is needed). How can I upgrade to this version? I suppose I just could…
holyredbeard
  • 19,619
  • 32
  • 105
  • 171
1039
votes
7 answers

Node.js/Windows error: ENOENT, stat 'C:\Users\RT\AppData\Roaming\npm'

I have Windows 7 32-bit. I installed the latest Node.js 32 bit. When I try to run the command npm install jquery, I receive the error: Error: ENOENT, stat 'C:\Users\RT\AppData\Roaming\npm How does one resolve it?
tryasko
  • 10,519
  • 3
  • 13
  • 6
1026
votes
31 answers

How to parse JSON using Node.js?

How should I parse JSON using Node.js? Is there some module which will validate and parse JSON securely?
Tikhon Jelvis
  • 67,485
  • 18
  • 177
  • 214
995
votes
32 answers

Upgrade Node.js to the latest version on Mac OS

Currently I am using Node.js v0.6.16 on Mac OS X 10.7.4. Now I want to upgrade it to the latest Node.js v0.8.1. But after downloading and installing the latest package file from nodejs.org, I found that system is still using v0.6.16 instead of…
afterglowlee
  • 11,670
  • 5
  • 22
  • 23
986
votes
19 answers

How to list npm user-installed packages

How do I list the user-installed / environment package only in npm? When I do npm -g list, it outputs every package and their dependencies. Instead I'd like to see the packages installed in the current working project or environment.
lolski
  • 16,231
  • 7
  • 34
  • 49
962
votes
39 answers

How to change node.js's console font color?

I had to change the console background color to white because of eye problems, but the font is gray colored and it makes the messages unreadable. How can I change it?
MaiaVictor
  • 51,090
  • 44
  • 144
  • 286