Which websocket library to use with Node.js? [closed]

Getting the ball rolling with this community wiki answer. Feel free to edit me with your improvements. ws WebSocket server and client for node.js. One of the fastest libraries if not the fastest one. websocket-node WebSocket server and client for node.js websocket-driver-node WebSocket server and client protocol parser node.js – used in faye-websocket-node faye-websocket-node WebSocket … Read more

How to solve npm error “npm ERR! code ELIFECYCLE”

Step 1: $ npm cache clean –force Step 2: Delete node_modules by $ rm -rf node_modules (rmdir /S /Q node_modules in windows) folder or delete it manually by going into the directory and right-click > delete / move to trash. If you are not updating your packages you can delete the package-lock.json file too. Step … Read more

Understanding passport serialize deserialize

Where does user.id go after passport.serializeUser has been called? The user id (you provide as the second argument of the done function) is saved in the session and is later used to retrieve the whole object via the deserializeUser function. serializeUser determines which data of the user object should be stored in the session. The … Read more

What does body-parser do with express?

Edit: in 2019-april-2 in express@4.16.0 the body-parser middleware is included in express, so you don’t need to install body-parser separately anymore. for more details see this OLD: To handle HTTP POST requests in Express.js version 4 and above, you need to install the middleware module called body-parser. body-parser extracts the entire body portion of an … Read more

How to clean node_modules folder of packages that are not in package.json?

I think you’re looking for npm prune npm prune [<name> [<name …]] This command removes “extraneous” packages. If a package name is provided, then only packages matching one of the supplied names are removed. Extraneous packages are packages that are not listed on the parent package’s dependencies list. See the docs: https://docs.npmjs.com/cli/prune

Express.js req.body undefined

UPDATE July 2020 express.bodyParser() is no longer bundled as part of express. You need to install it separately before loading: npm i body-parser // then in your app var express = require(‘express’) var bodyParser = require(‘body-parser’) var app = express() // create application/json parser var jsonParser = bodyParser.json() // create application/x-www-form-urlencoded parser var urlencodedParser = … Read more

How to determine a user’s IP address in node

In your request object there is a property called socket, which is a net.Socket object. The net.Socket object has a property remoteAddress, therefore you should be able to get the IP with this call: request.socket.remoteAddress (if your node version is below 13, use the deprecated now request.connection.remoteAddress) EDIT As @juand points out in the comments, … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)