Node.js® is a JavaScript runtime built on Chrome's V8 JavaScript engine. Node.js uses an event-driven, non-blocking I/O model that makes it lightweight and efficient. Node.js' package ecosystem, npm, is the largest ecosystem of open source libraries in the world.

Share tech news, updates, or what's on your mind.

Sign up to Post

Hello, I want to make localization for my electron app. It works, if I use the second countryCode, but if I require the countryCode it the first 3 .text function dont work. The .val-s working everytime.

const $ = require('jquery');
const {app, remote, ipcRenderer} = require('electron');
const fs = require('fs');

// var countryCode = require('electron').remote.getGlobal('sharedObject').cc;
var countryCode = 'en';

fs.readFile('localization/' + countryCode + '.json', function(err,data) {
  if(err) throw err;
  var json = JSON.parse(data);


Open in new window

Turn Raw Data into a Real Career
Turn Raw Data into a Real Career

There’s a growing demand for qualified analysts who can make sense of Big Data. With an MS in Data Analytics, you can become the data mining, management, mapping, and munging expert that today’s leading corporations desperately need.

So i have a user schema like this:

var user_schema = new Schema({
   username:{type:String,required: true, unique : true, trim: true},
   college:{type:String,required: true},
   password:{type:String,required: true, trim: true},
   email:{type:String,required: true, unique : true, trim: true},
   phone:{type:Number,required: true, unique : true, trim: true},

Open in new window

and my objective is, to search the all the documents in the collection to get people based on the following conditions:

1. They should not be in the users' "friends" array.
2. They should not be in the users' "pending" array.
3. They should have the same "tag" (a string value) as the user.

So, basically I have to compare the users' fields ("friends","pending" and "tags"), with fields of all documents in the whole collection.

How do I do it, using mongoose (nodejs mongodb library)
I have to initialize an array to [](empty array) and then push user chose "tags" into it. This is my schema:

 var user_schema = new Schema({
   username:{type:String,required: true, unique : true, trim: true},
   college:{type:String,required: true},
   password:{type:String,required: true, trim: true},
   email:{type:String,required: true, unique : true, trim: true},
   phone:{type:Number,required: true, unique : true, trim: true},

Open in new window

` and i have to initialize "tags" to [] and push user string values (user entered/chosen) every time the request is made to the API call.

I am using this line of code:

   { _id: },
   { $set:{tags:[]},$push: { tags: 'some chosen string'  } },
  function (error, success) {
         if (error) {
        } else {

Open in new window

But it's not working.
I'm a complete beginner so I may have made some stupid mistakes. I made this script with x-ray to scrape user's phone number pictures from different website pages. The script was working very well until it reaches a page where the user didn't put his number in the page and the script stops.

How can I make it continue to the next page even if the phone number doesn't exist? and is there a way to make the script save the pictures directly to my computer instead of giving me the links?
 const Xray = require('x-ray');
const requesst = require('request');
const fs = require('fs');

const xray = Xray()

xray(',-caméscopes/annonce/6503723/Nikon-D40x-objectif-18-135mm.html', 'div.infoannonce', [{
	numero: '#phone_number img@src',
	nom: '.infoannonce dd',


Open in new window

i'm beginner to Node JS and javascript. Now everybody is saying to learn Node JS and javascript to develop a fastest, scalable and very good web application.

I thought of developing via Zk or Vaadin framework and experts says Node Js and javascript is far better than Zk or Vaadin

Could someone help with the thoughts and recommendation of which one to go and which one would be fast, reliable and scalable?

Like word press plugins, zk and vaadin components, Do we have a best java script framework which has huge components to integrate and create a beautiful and fastest responsive web app?

How to enable the movement of my html files in handlebars or .ejs? I have intended an html template in an .ejs file inside my node views and the slider does not move, another script that should move some numbers directly shows static without dynamism. How to solve this problem?

In my templating engine .ejs i can t see this 2 animations: (slider and animation numbers)

ejs slider

ejs animation
Hear is the code:

The slider and the animation numbers in html:

html slider and animation looks nice the move is great.

I need use ejs this is the problem.
Somebody know how do this?
I have the google c# api code and it works fine.But I want to get
child node : photos {height and width}.
open now
weekday text

Can you help me what I need to do with the codes below? Thank


protected void Page_Load(object sender, EventArgs e)
             WebClient wc = new WebClient();
            string jsonStr = wc.DownloadString(",-122.443&radius=10000&type=rv_park&key=AIzaSyCietasdfasdfasdfasdfxzD65Uc19X6DgrJFumdi-nCZYSHjg");
            GooglePlacesResponse gpr = (GooglePlacesResponse)JsonConvert.DeserializeObject<GooglePlacesResponse>(jsonStr);
            Response.Write(gpr.status + "<br><br>");
            foreach (results r in gpr.results)
                    ( + " "  + 
            + " " + 
                     r.geometry.location.lng + " " +
                     r.reference + " " +
                     r.vicinity  + " " +                         

        public class GooglePlacesResponse
            public string status { get; set; }
            public results[] results { get; set; }
        public class results
            public geometry geometry { get; set; }

Open in new window

I have a Node project written in TypeScript where the application takes in user's input arguments and does some calculation and prints out the results. Take the example of a calculator the user inputs value of two numbers and it prints out the addition of two numbers. for example npm run calc 3 5. The application prints out 8.

The application is working but i want to make this an aws lambda function and deploy it in aws. The examples i see everywhere is hello lambda function. Can anyone help me how i can make a handler and deploy it to aws?

How do i convert the below hello function to a calc lambda function and deploy it to aws?
export const hello: Handler = (event: APIGatewayEvent, context: Context, cb:             
Callback) => {
const response = {
statusCode: 200,
body: JSON.stringify({
message: 'Go Serverless Webpack (Typescript) v1.0! Your function executed 
  input: event,

cb(null, response);

Open in new window

This is my addition class

export class Calc {
public static add(){

    console.log( this.addition( (process.argv[0] + process.argv[1] ));

public static addition(num1:number, num2:number)
    return num1 + num2;

Open in new window


My manager asked me updating a website from codeigniter to  
backend: API using PHP (Symfony) or node (expressjs) or Drupal 8 . or any other framework. can you give me explanations?

And for single page applications Angular 4 or Vue js
Hey, This is just a decision-making problem. I am seeking for a well thought out answer.
I have to develop an android XMPP chat application, (the application also has a NodeJS server API, connecting to MongoDB and AWS S3 for picture uploads)

which will be better:

1. Having a "openfire" server on aws and connecting it to the android application and implementing an XMPP client on the android device using "smack" library.

2. Implementing a "xmpp-client" on NodeJS server side and scrape the results from this API to the Android device.
Increase Security & Decrease Risk with NSPM Tools
Increase Security & Decrease Risk with NSPM Tools

Analyst firm, Enterprise Management Associates (EMA) reveals significant benefits to enterprises when using Network Security Policy Management (NSPM) solutions, while organizations without, experienced issues including non standard security policies and failed cloud migrations

We had same issue but unable to find cause. it happened at random time.No logs from ESX host,network switch. looks it is not communicating internally.error :
Cluster network interface 'node-03 - VLAN 10' for cluster node 'node-03' on network 'Cluster Network 1' failed. Run the Validate a Configuration wizard to check your network configuration. If the condition persists, check for hardware or software errors related to the network adapter. Also check for failures in any other network components to which the node is connected such as hubs, switches, or bridges.
Please advise solution
i have a node that contains (america-germany) and  another node contain (america&#x02010;germany),when i check for this node are equals or not it say it is not Equal, i am using java with dom parser ,but when i put entity value(&#x02010;) in both node it say Equal,why can anyone help me
I have glassfish app on my Linux red hat 6.
I cant start my glassfish node it gives me next error :

There is a process already using the admin port 5858 -- it probably is another instance of a GlassFish server.Command start-domain failed.

But when i run comman in linux " netstat -tulnp | grep 5858 " It shows me:

tcp :::5858 LISTEN 47256/java

Port used by java app. But i cant log in to my glassfish interface.

How can i solve this issue, any expierenced specialist with glassfish maybe can help.
25 development practices our NodeJS developers follow

Node.js, a JavaScript runtime built on Google V8 JavaScript engine employs an event-driven, non-blocking I/O model that makes way for lightweight and efficient web applications. This blog introduces you to some 25 of best of its practices.
Read more :
i am trying to run

npm install mysql

command in cmd its giving me these error

npm ERR! Unexpected end of JSON input while parsing near '....tgz"},"engines":{"no'

npm ERR! A complete log of this run can be found in:

npm ERR! C:\Users\HP\AppData\Roaming\npm-cache\_logs\2018-05-30T06_49_09_337Z-debug.log
I am writing a proxy app in nodejs which handles thousands of concurrent connections inwards and outwards, I want to make sure all idle and unneeded and ... connections get closed properly and their file descriptors get released. If it leaks file descriptors, I would run out of them very fast. my question is that what is the best solution to make sure a connection gets closed ? socket.end() or socket.destroy() ? currently I am using socket.end() but in doc it says it half closes the connection, is there a situation that socket.end() doesnt result in closing a connection ? what I am interested in is releasing the file descriptors ASAP. So what do you suggest ?
When I am trying to secure the users API; I am getting always 401 unauthorized. I have tried different variations to define strategy; but no luck. I have been using JWTStrategy and using jwtwebtoken while signing the token with the Secret and RS256 Algorithm


// import * as module from 'module';
  User = require('../models/user'),
  JwtStrategy = require('passport-jwt').Strategy,
  ExtractJwt = require('passport-jwt').ExtractJwt,
  config = require('./appconfig');

// Setting JWT strategy options
const jwtOptions = {
  // Telling Passport to check authorization headers for JWT
  jwtFromRequest: ExtractJwt.fromAuthHeaderWithScheme('Bearer'),
  // Telling Passport where to find the secret
  secretOrKey: config.jwtSecret,
  // TO-DO: Add issuer and audience checks

module.exports = function(passport) {
  passport.use(new JwtStrategy(jwtOptions, function(jwt_payload, done) {
    User.findOne({id: jwt_payload.sub}, function(err, user) {
      if (err) {
          return done(err, false);
      if (user) {
          return done(null, user);
      } else {
          return done(null, false);
          // or you could create a new account

Open in new window

const express = require('express');
const userRoutes = require('./user.route');
const authRoutes = require('./auth.route');
// const postRoutes = require('./post.route');
const passport = require('passport');

var jwt = require('../config/passport')(passport);

const router = express.Router(); // eslint-disable-line new-cap

/** GET /health-check - Check service health */
router.get('/health-check', (req, res) =>

// mount user routes at /users
router.use('/users', passport.authenticate('jwt', { session: false }), userRoutes);

// mount auth routes at /auth
router.use('/auth', authRoutes);

// router.use('/posts', postRoutes);

module.exports =  router;

Open in new window

Using Postman: Header: Authentication: JWT Token

I am unable to install nodejs on Solaris-10 x86 server. It is complaining about some libraries . Can somebody guide on this ?
-bash-3.2# cat /etc/release
                    Oracle Solaris 10 1/13 s10x_u11wos_24a X86
  Copyright (c) 1983, 2013, Oracle and/or its affiliates. All rights reserved.
                            Assembled 17 January 2013
-bash-3.2# pwd
-bash-3.2# ./node node: fatal: version 'SUNW_1.7' not found (required by file node) node: fatal: open failed: No such file or directory
-bash-3.2# ldd node =>         /lib/64/ =>  /lib/64/ =>        /lib/64/ (SUNW_1.7) =>     (version not found) =>   /lib/64/ =>      /lib/64/ =>        (file not found) =>     /lib/64/ =>    /lib/64/ =>         (file not found) =>       /lib/64/ =>     /lib/64/ (ILLUMOS_0.17) =>      (version not found) (ILLUMOS_0.8) =>       (version not found) =>    /lib/64/ =>    /lib/64/ =>   /lib/64/

Open in new window

Hi EE,

At the moment, I'm hosting my website on Heroku, and have come about a very frustrating issue I don't know how to approach.

My app uses React.js and Node.js -
In the index file (server.js), the following logic is used:

const express = require('express');
const fs = require('fs');
const path = require('path');

var app = express();
var PORT = process.env.PORT || 3001;

if ( process.env.NODE_ENV === "production" ) {
  app.get( '/*',  function ( req, res )  {
    app.use(  express.static("client/build")  );//This is the index.html that was build with React

app.listen(PORT, ()=>console.log('listening on port ' + PORT))

Open in new window

What the code does :
If we are in production, grab the build that was made in React.js and render it.

Here comes the problem..

When on the homepage,(  `/` )it renders perfectly.
But when we try to go somewhere like `about` or `contact`, Heroku will give me an error, because it thinks I'm making a request to the back end.

The React routing looks something like this:
class App extends Component {
  render() {
    return (
        <Route exact path='/' component={Landing}/>
        <Route path='/blogs' component={Blogs}/>
        <Route path='/blog' component={Blog}/>
        <Route path='/contact' component={Contact}/>

        <Route path="/ping" component={Pong} />

Open in new window

Any insights into dealing with this deadly bug are greatly appreciated
Making Bulk Changes to Active Directory
Making Bulk Changes to Active Directory

Watch this video to see how easy it is to make mass changes to Active Directory from an external text file without using complicated scripts.

I am trying to setup Mongoose and when I run NPM start I get the following error

Error: Cannot find module '.routes/users'
    at Function.Module._resolveFilename (module.js:547:15)
    at Function.Module._load (module.js:474:25)
    at Module.require (module.js:596:17)
    at require (internal/module.js:11:18)
    at Object.<anonymous> (/Users/leotyndall/Desktop/node/nodeexpress/nodewebapp/app.js:12:13)
    at Module._compile (module.js:652:30)
    at Object.Module._extensions..js (module.js:663:10)
    at Module.load (module.js:565:32)
    at tryModuleLoad (module.js:505:12)
    at Function.Module._load (module.js:497:3)
    at Module.require (module.js:596:17)
    at require (internal/module.js:11:18)
    at Object.<anonymous> (/Users/leotyndall/Desktop/node/nodeexpress/nodewebapp/bin/www:7:11)
    at Module._compile (module.js:652:30)
    at Object.Module._extensions..js (module.js:663:10)
    at Module.load (module.js:565:32)
npm ERR! errno 1
npm ERR! nodewebapp@0.0.0 start: `node ./bin/www`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the nodewebapp@0.0.0 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

i do have a folder with the routes/ see the file uploaded

I am lost why it wont run
I'm having difficulty putting a complex(to me) aggregation query together for my data. Basically, here's the run down so everyone understands my conundrum.

I have two collections in this equation. "training_documents" and "users". Each user object has a key identified by name "trainings" which is an array of objects. Each object within this trainings array, contains 4 key/value pairs. An example of each object is below.

    	"document": ObjectId('5a0350ad7df0977d94cffab6'),
    	"trainee": ObjectId('59e51a4b7df0977d94cff95d'),
    	"trainer": ObjectId('595fcc2e04cf707693257890'),
    	"completion_time": "2018-04-23T21:28:22.747Z"

Open in new window

The users trainings array will contain many objects following the aforementioned format.

An example user data structure is below for reference.

    		"_id": "5ad782283c55b056bcc39e3z",
    		"site": {
    			"site_id": "site1",
    			"site_name": "Site One"
    		"user_name": "jsmith",
    		"first_name": "John",
    		"middle_name": "A",
    		"last_name": "Smith",
    		"full_name": "John Smith",
    		"title": "Duh Boss...",
    		"email": "",
    		"last_login": "2018-04-27T14:27:27.014Z",
    		"type": "full-time",
    		"active": true,
    		"__v": 0,
    		"badge_id": "000001780343232123",
    		"trainings": [
    				"document": ObjectId('5ae33622a766885a121b7362'),

Open in new window

I'm trying to copy from table from one table to another. So i want to stream the large data in and as it comes in I want to copy the contents of that data to another table. Its more then just a straight copy. I will probably massage the data a bit and then copy it over to the new table. The problem that I'm having is that row event keeps firing and I can't control it. I tried using async and await where I was hoping to make it stop but does not seem to be working. I can't control an event from firing or not. This is what I have so far. So basically I want to simulate a cursor in MSSQL. I don't want to download all the data and then do operations on it.

I'm not showing the massaging of the data below since I just want to see if I can copy data from one table to another.

var fs = require('fs');
var sql = require('mssql');
var sql2 = require('mssql');
var Request = require('tedious').Request; 
var TYPES = require('tedious').TYPES;  
var SqlString = require('sqlstring');

const config = {
    user: 'xxxx',
    password: 'xxx',
    server: 'xxxx\\',
    port: 'xxxx',
    database: 'xxxx',
    options: {
        instanceName: 'sql2014'

function insertRecord(pool, record){
    return new Promise(function(resolve, reject){

        const request = pool.request();

        request.input('invoice_id', sql.Int, record.invoice_id);

        request.query('INSERT INTO _invoice_temp(invoice_id)  VALUES(@invoice_id)', (err, result) => {

Open in new window

sir i have a list :that contain some value : after i am geeting node content value: and cheak that node content value contains list value or not:but i am getting exception because list not converted to charsequence : my code is List<String> xx = new ArrayList<String>(); xx.add("Van"); xx.add("Von"); xx.add("Le"); DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); DocumentBuilder builder = factory.newDocumentBuilder(); Document d = builder.parse(file); d.getDocumentElement().normalize(); String[] s = xx.toArray(new String[xx.size()]); NodeList ndlist = d.getElementsByTagName("personName"); for (int i = 0; i < ndlist.getLength(); i++) { Node node = ndlist.item(i); NodeList nl = node.getChildNodes(); for (int j = 0; j < nl.getLength(); j++) { Node node1 = nl.item(j); if (node1.getNodeName().equals("givenNames")) { Element element = (Element) node1; String str = element.getTextContent().toUpperCase(); if(str.contains(xx))//error list cannot convert to charsequence { //some opration } } }
Getting app.js:249 Service Worker Error TypeError: Failed to register a ServiceWorker: A bad HTTP response code (404) was received when fetching the script. When trying to access the service worker using JavaScript. Need help ASAP. I can add my code if needed.
I'm currently doing a small from which only contains a html5 pages .. index.html.

Currently I am adding the javascript code to the actual page between script tags.

What I want to do is to create an ES6 module and import it to to this index.html page.

But I want to do this without having to use node, angular or react in a project.

What is the easiest ay to do this with my layout?






Node.js® is a JavaScript runtime built on Chrome's V8 JavaScript engine. Node.js uses an event-driven, non-blocking I/O model that makes it lightweight and efficient. Node.js' package ecosystem, npm, is the largest ecosystem of open source libraries in the world.

Top Experts In