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 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 the 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 it is 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

388627 questions
1026
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
  • 12,208
  • 5
  • 23
  • 34
1011
votes
21 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
  • 57,724
  • 41
  • 114
  • 149
997
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
  • 64,915
  • 16
  • 168
  • 210
997
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,099
  • 3
  • 11
  • 6
991
votes
17 answers

Sending command line arguments to npm script

The scripts portion of my package.json currently looks like this: "scripts": { "start": "node ./script.js server" } ...which means I can run npm start to start the server. So far so good. However, I would like to be able to run something like…
arnemart
  • 10,310
  • 3
  • 14
  • 9
965
votes
7 answers

How to 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 hex, binary or ascii data. For example: var cipher = crypto.createCipheriv('des-ede3-cbc', encryption_key, iv); var ciph =…
murvinlai
  • 43,517
  • 50
  • 120
  • 169
937
votes
17 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
  • 9,514
  • 3
  • 11
  • 13
884
votes
35 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
  • 10,648
  • 7
  • 34
  • 51
864
votes
11 answers

npm WARN package.json: No repository field

I installed Express.js with the following command: sudo npm install -g express I get the following warnings: npm WARN package.json range-parser@0.0.4 No repository field. npm WARN package.json fresh@0.1.0 No repository field. npm WARN package.json…
JR Galia
  • 16,343
  • 19
  • 84
  • 143
832
votes
19 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
  • 25,656
  • 28
  • 106
  • 180
830
votes
23 answers

How to access POST form fields

Here is my simple form:
murvinlai
  • 43,517
  • 50
  • 120
  • 169
813
votes
25 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
  • 9,680
  • 5
  • 17
  • 23
812
votes
34 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
  • 15,990
  • 29
  • 94
  • 163
793
votes
11 answers

Node.js Best Practice Exception Handling

I just started trying out node.js a few days ago. I've realized that the Node is terminated whenever I have an unhandled exception in my program. This is different than the normal server container that I have been exposed to where only the Worker…
momo
  • 20,477
  • 8
  • 36
  • 38
779
votes
24 answers

module.exports vs exports in Node.js

I've found the following contract in a Node.js module: module.exports = exports = nano = function database_module(cfg) {...} I wonder whats the different between module.exports and exports and why both are used here.
Andreas Köberle
  • 88,409
  • 51
  • 246
  • 277