What is Node.js’ Connect, Express and “middleware”?

[Update: As of its 4.0 release, Express no longer uses Connect. However, Express is still compatible with middleware written for Connect. My original answer is below.] I’m glad you asked about this, because it’s definitely a common point of confusion for folks looking at Node.js. Here’s my best shot at explaining it: Node.js itself offers … Read more

bodyParser is deprecated express 4

It means that using the bodyParser() constructor has been deprecated, as of 2014-06-19. app.use(bodyParser()); //Now deprecated You now need to call the methods separately app.use(bodyParser.urlencoded()); app.use(bodyParser.json()); And so on. If you’re still getting a warning with urlencoded you need to use app.use(bodyParser.urlencoded({ extended: true })); The extended config object key now needs to be explicitly … Read more

How to use executables from a package installed locally in node_modules?

UPDATE: As Seyeong Jeong points out in their answer below, since npm 5.2.0 you can use npx [command], which is more convenient. OLD ANSWER for versions before 5.2.0: The problem with putting ./node_modules/.bin into your PATH is that it only works when your current working directory is the root of your project directory structure (i.e. … Read more

Node.js on multi-core machines

[This post is up-to-date as of 2012-09-02 (newer than above).] Node.js absolutely does scale on multi-core machines. Yes, Node.js is one-thread-per-process. This is a very deliberate design decision and eliminates the need to deal with locking semantics. If you don’t agree with this, you probably don’t yet realize just how insanely hard it is to … Read more

Node Sass couldn’t find a binding for your current environment

I had the same problem There is an error in your gulpfile: Error: Missing binding E:\allapp\badshaindiancuisine\node_module\node-sass\vendor\win32-x64-46\binding.node Node Sass could not find a binding for your current environment:Windows 64-bit with Node.js 4.x Found bindings for the following environment:     – OS X 64-bit with Node.js 4.x How to solve the problem By going into the … Read more

Read a file one line at a time in node.js?

Since Node.js v0.12 and as of Node.js v4.0.0, there is a stable readline core module. Here’s the easiest way to read lines from a file, without any external modules: const fs = require(‘fs’); const readline = require(‘readline’); async function processLineByLine() { const fileStream = fs.createReadStream(‘input.txt’); const rl = readline.createInterface({ input: fileStream, crlfDelay: Infinity }); // … Read more