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
67
votes
6 answers

What's the most efficient node.js inter-process communication library/method?

We have few node.js processes that should be able to pass messages, What's the most efficient way doing that? How about using node_redis pub/sub EDIT: the processes might run on different machines
DuduAlul
  • 5,822
  • 7
  • 34
  • 61
67
votes
31 answers

internal/modules/cjs/loader.js:582 throw err

I'm getting following Console Error. Error : Cannot find module Here is the full error i'm getting in console. What should I do? internal/modules/cjs/loader.js:582 throw err; ^ Error: Cannot find module…
67
votes
4 answers

Receiving email in Node.js

I see a lot of Node.js modules out there that sends mail through SMTP. But is there a module to receive mail?
foobar
  • 9,276
  • 14
  • 46
  • 63
67
votes
5 answers

How to fill an input field using Puppeteer?

I'm using Puppeteer for E2E test, and I am now trying to fill an input field with the code below: await page.type('#email', 'test@example.com'); It worked, but I found the email address was typed into the field one character by one character as if…
choasia
  • 8,394
  • 4
  • 34
  • 51
67
votes
5 answers

GraphQL Expected Iterable, but did not find one for field xxx.yyy

I'm currently trying GraphQL with NodeJS and I don't know, why this error occurs with the following query: { library{ name, user { name email } } } I am not sure if the type of my resolveLibrary is right, because at any…
Vetterjack
  • 1,519
  • 3
  • 13
  • 22
67
votes
7 answers

Make node.js not exit on error

I am working on a websocket oriented node.js server using Socket.IO. I noticed a bug where certain browsers aren't following the correct connect procedure to the server, and the code isn't written to gracefully handle it, and in short, it calls a…
RobKohr
  • 5,745
  • 7
  • 40
  • 58
67
votes
2 answers

How to set the content-type of request header when using Fetch APi

I am using npm 'isomorphic-fetch' to send requests. The problem I am experiencing is I am unable to set the content-type of the request header. I set a content type of application/json , however the request header are being set to text/plain. import…
user1526912
  • 10,370
  • 11
  • 49
  • 81
67
votes
18 answers

Cannot find runtime 'node' on PATH - Visual Studio Code and Node.js

With a downloaded and installed version of Visual Studio Code 1.2.1, and a 64bit version of node.exe msi placed in my working directory (I am assuming that is correct), how do we add node and npm command line tools to be on our PATH? I am confused…
klewis
  • 5,905
  • 9
  • 52
  • 89
67
votes
5 answers

Running a node express server using webpack-dev-server

I'm using webpack to run my react frontend successfully using the following config: { name: 'client', entry: './scripts/main.js', output: { path: __dirname, filename: 'bundle.js' }, module: { loaders: [ …
Øyvind Bråthen
  • 54,098
  • 26
  • 117
  • 143
67
votes
1 answer

NPM : how to just run post-install?

Just a simple question : in my node.js project, how could I just run the postinstall script, without running install before ? FYI, this is my package.json : { "name": "gestionclientjs", ..., "dependencies": { ... }, "repository": {}, …
noelm
  • 1,131
  • 1
  • 7
  • 13
67
votes
7 answers

Upload a file to Amazon S3 with NodeJS

I ran into a problem while trying to upload a file to my S3 bucket. Everything works except that my file paramters do not seem appropriate. I am using Amazon S3 sdk to upload from nodejs to s3. These are my routes settings: var multiparty =…
Maximus S
  • 9,379
  • 18
  • 67
  • 140
67
votes
1 answer

Is there an efficiency difference between const vs var while 'requiring' a module in NodeJS

I was reading the documentation for https://github.com/rvagg/bl and I noticed that, in the examples, they use const to require a module and this made me wonder: is this a good practice? I mean, to me, this looked as a good idea. A direct example…
Hugo
  • 5,484
  • 7
  • 35
  • 43
67
votes
4 answers

How to check in node if module exists and if exists to load?

I need to check if file/(custom)module js exists under some path. I tried like var m = require('/home/test_node_project/per'); but it throws error when there is no per.js in path. I thought to check with fs if file exists but I don't want to add…
Damir
  • 48,513
  • 89
  • 234
  • 352
67
votes
1 answer

What the scenario call fs.close is necessary

I can't find more about fs.close explain in nodejs API. I want to know what the scenario call fs.close is necessary. for example: var fs = require('fs'); fs.writeFile("/home/a.tex","abc"); or like fs.appendFile("/home/a.tex","close") fs.close();…
L.T
  • 2,287
  • 2
  • 17
  • 28
67
votes
9 answers

How can I solve "ReferenceError: expect is not defined" error message?

I am trying to test Javascript with mocha. I've this snippet of code: describe('Array', function() { describe('indexOf()', function() { it("dovrebbe tornare -1 quando l'elemento non è presente", function() { …
sensorario
  • 15,862
  • 24
  • 85
  • 131
1 2 3
99
100