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

I have this function 'loadSong' that I got from an example on the net. It works fine.

I now want to make 'songName' assigned the value retrieved from a QueryString, such as

How can I do that please?

This is a Node.js application I have running on my local machine where I am testing. Eventually it will be on a Node hosting plan (Heroku).


function loadSong(songName) {

    // This function builds the current
    // song and resets all states to default (zero muted and zero solo lists, all
    // volumes set to 1, start at 0 second, etc.)
    currentSong = new Song(songName, context);

// I NEED THE VARIABLE songName to be the value of a querystring. For example, from
// localhost:3000?songName=Imagine


    var xhr = new XMLHttpRequest();'GET', currentSong.url, true);

    xhr.onload = function (e) {
        // get a JSON description of the song
        var song = JSON.parse(this.response);

        // resize canvas depending on number of samples

        // for eah instrument/track in the song
        song.instruments.forEach(function (instrument, trackNumber) {
            // Let's add a new track to the current song for this instrument

            // Render HTMl
            var span = document.createElement('tr');

Open in new window

Percona Live Europe 2017 | Sep 25 - 27, 2017
Percona Live Europe 2017 | Sep 25 - 27, 2017

The Percona Live Open Source Database Conference Europe 2017 is the premier event for the diverse and active European open source database community, as well as businesses that develop and use open source database software.

I'm using one of the free Wordpress themes 'SELA'.

On this page I want the lower iFrame (the multitrack player) to extend across the page. At the moment it is restricted, even though the page template is called 'Wide Page'. The width of the iFrame is set to 1200px.

These seems to be a restriction on the theme that prevents a full width iFrame. How can I get round that please?
I'm trying to understand how this works so that I can make a few small tweeks.

When the page opens a dropdown list is populated, and a song selection can be made.
I can see that a Function loadSong(songName) { ...} is fired off at that point. (it is in sounds.js)

I have found that I can force the song by doing this on line 342
currentSong = new Song("Londres Appelle", context);

Open in new window

"Londres Appelle" is a song in the demo list.

My question is, would it be possible to force a 'song' in this function by using a URL parameter?
eg."Londres Appelle"

My background: JavaScript and Node.js newbie. Worked extensively with Classic ASP and VBScript back in the day  (2001-2003). I understand using QueryString to pass a variable to a page, but I don't know if I need to think differently in Node.js.

I am building a registration form in node.js using mongoDB.  When I submit my form, it shows blank.  Any ideas?

Here's my code.

vendor.js in my models forlder
//Create model for vendor
const mongoose = require('mongoose');
const Schema = mongoose.Schema;

//Schema for vendor
const vendorSchema = new Schema({
  firstName: String,
  lastName: String,
  phoneNumber: String,
  email: String,
  description: String,
  businessName: String

const Vendor = mongoose.model( 'Vendor', vendorSchema );

module.exports = Vendor

Open in new window

vendor.js in my routes folder
const express = require('express')

const Vendor = require('../models/vendor.js')

const vendorRouter = express.Router()

//define Routers
//url: Localhost:3000/vender/registration
console.log("Vendor Router")

vendorRouter.get('/', (req,res) =>{
})'/thanks', (req, res) => {
  let newVendor = new Vendor({
    firstName: req.body.firstName,
    lastName: req.body.lastName,
    phoneNumber: req.body.phoneNumber,
    description: req.body.description,
    businessName: req.body.businessName

vendorRouter.get('/thanks', (req,res) =>{

vendorRouter.get('/forgotpassword', (req, res) => {

module.exports = vendorRouter

Open in new window

img dir
Here's how I know blanks are coming in.  Table is populated but noting is showing
Here's the page using handlebars
<table id="tblArtist" class="display" cellspacing="0" width="100%" border="1">
    <th>First Name</th>
    <th>Last Name</th>
		<th>Phone Number</th>
{{#each vendors }}
    <td>{{ firstName }}</td>
    <td>{{ lastName }}</td>
    <td>{{ phoneNumber }}    </th>
    <td>{{ email }} </td>

Open in new window

Hi experts,
aI'm trying to update nodejs version , i try this command lines :
I don't understand why  it can't be updated
PS: am using linux mint 17.2
Hello I want to change my node location from "TOP" to "warehouse". Can someone please tell me the command?
Hi all

The UI for my react app has a main section (takes up most of the screen) and a left hand side pane.
I'm using 3 separate ag-grids:
-One as the main one on the main screen holding the important data.
-the other two are in the left hand side pane (the less important grids for assistance/statistic holding).

This left pane uses (two) tabs, i.e. click on one tab to see one ag-grid, click the other tab to see the other ag-grid

For the tab functionality, i used npm to install the NPM react-bootstrap-tabs node module.

Recently I managed to set up one of the left pain ag-grids to hold filtering information from the main grid.
This was quite a hassle since the grids were effectively grand-sibling components which needed to communicate. without touching AG-grid src code, I had to set up ag-grid callbacks to take note of the filtering data from the main ag-grid, send it up to the grandparent component of my app, and then send it back down to the other grand child ag-grid component.

It all works however I noticed a glitch. When initially loading the whole page, the first tab in the left pane is active by default. The left pane ag-grid that holds the filter information is in the second tab. What I want is to click on this second tab, and see filter data be populated automatically as i filter the main ag-grid. However when I have the second tab active and i filter the main ag-grid (i.e. adding filter …
Hello nodejs experts

Is there is anything more on node js standards?  

All urls must be in lower case

Ex: /notification/sendotp

Use HTTP verbs (GET, POST, PUT, DELETE) to operate on the collections and elements.

Use GET – for retrieving single or list data

Use POST – for create data

Use PUT – for update data

Use DELETE – for delete data











URLs should include nouns, not verbs in API names. Avoid get,update,save, delete, list in API names.

Maintain singular and plural nouns for APIs.

Ex: for single image retrive – GET - /user/image

For list of images – GET – user/images

User Token must be in headers only. Not as path param or in json body

Use resource, sub-resources for relations

Ex: for user videos use - /user/videos

Put the version number at the base of your URL. /v1/user/images

Controller will have only mandatory parameter validations and sending success, error responses no business logic. Use Service and Helper files for business logic. DAO for db calls

Handle Errors with HTTP status codes

200 – OK – Everything is fine. Created, Saved, Data found

400 – Validations Failed, Missing Mandatory Params, No data found, User already exists, already voted, in valid comment, comment not allowed within a hour, invalid user, invalid video, Video not found

500 – Unknown error, Database error, ES down, timeout from third-party. …
I'm trying to setup a new webrtc instance behind the firewall where tcp 80 and 443 ports are only available.
All is fine as long as udp ports are enabled. Once I block udp, I can't establish a client connection.
The stun/turn server has been setup however connections are not redirected from webrtc.

RTCMultiConnection.js config:

var IceServersHandler = (function() {
        function getIceServers(connection) {
            var iceServers = [];
iceServers.push(getTURNObj('', 'user', 'pass'));
            if (window.RMCExternalIceServers) {
                iceServers = iceServers.concat(getExtenralIceFormatted());
            } else if (typeof window.getExternalIceServers !== 'undefined' && window.getExternalIceServers == true) {
                connection.iceServers = iceServers;
                window.iceServersLoadCallback = function() {
                    connection.iceServers = connection.iceServers.concat(getExtenralIceFormatted());

            return iceServers;

        return {
            getIceServers: getIceServers

turnserver.conf config


All is running in AWS cloud.

I am learning Angular, Node, npm, deployd, mongodb, etc.  I am making my way through a book titled "Pro AngularJS" by Adam Freeman.

on page 120 I am attempting to prepare the data for a "real world" application called "sportsstore".

I was instructed to install a module called "deployd" which apparently is used for modelling  API's for web applications.

I did that and when I try to start start the "deployd" service I get an error:

C:\PROGRA~2\deployd>dpd -p 5500 sportsstore\app.dpd --mongod
starting deployd v0.8.9...
  var err = this._handle.spawn(options);

TypeError: Bad argument
    at TypeError (native)
    at ChildProcess.spawn (internal/child_process.js:289:26)
    at exports.spawn (child_process.js:380:9)
    at Object.exports.restart (C:\Users\knowlton\AppData\Roaming\npm\node_modules\deployd\lib\util\mongod.js:38:14)
    at Command.start (C:\Users\knowlton\AppData\Roaming\npm\node_modules\deployd\bin\dpd:149:16)
    at Command.listener (C:\Users\knowlton\AppData\Roaming\npm\node_modules\deployd\node_modules\commander\index.js:301:8)
    at emitOne (events.js:96:13)
    at Command.emit (events.js:188:7)
    at Command.parseArgs (C:\Users\knowlton\AppData\Roaming\npm\node_modules\deployd\node_modules\commander\index.js:617:12)
    at Command.parse (C:\Users\knowlton\AppData\Roaming\npm\node_modules\deployd\node_modules\commander\index.js:458:21)
    at Object.<anonymous> 

Open in new window

Watch the Recording: Learning MySQL 5.7
 Watch the Recording: Learning MySQL 5.7

MySQL 5.7 has a lot of new features. If you've dabbled with an older version of MySQL, it is definitely worth learning.

I have to write a Node.JS application that connects to a remote server.  The remote server has a login manager that authenticates my session then spawns a separate process to handle the rest of my session.  The way that works is that I have to make a non-SSL network connection to the login manager and do an initial unprotected handshake.  The lets the client and server negotiate if they will be doing SSL or plain text communications.  If SSL then I need to elevate my socket to an SSL socket, send my login and password along with some other initial information, then get a success of failure message back from the login manager.  If success then I know the login manager is starting a new process and handing off my open socket connection to that new process.  Since the server can't pass the SSL context it de-elevates the SSL connection and runs a program passing it the non-SSL open socket.  Then the new program creates it's own SSL context on the open socket. So in my Node.JS code I need to close the SSL socket but leave the raw socket open.  The new program will send me a success message when it is up and running at which time I need to re-elevate my open socket to SSL again.

My question is how can I close an SSL socket leaving the raw socket open so I can continue to use the raw socket and then re-elevate it to SSL again?
I have a node.js module that needs unit test. Here is the key relevant code:

old code:
                const memsqlPool = {
                    execute: sandbox.stub().resolves(!mockPara || mockPara.memSqlResult || ''),
                sandbox.stub(my-lib.memsql, 'Pool', constant(memsqlPool));

In the source code:

const {memsql} = require('my-lib');
const memsqlPool = new memsql.Pool(my-config);
        function getInfo(id){
            return memsqlPool.execute(my-arguments).then(my-mapping-object);

This code actually hints that memsqlPool.execute() can only be called once in any given test case, because it always returns the same results.
Now I have to make two memsql calls, one depends on another.  I try to make it something like:


But just do not know how to fit this idea into the unit test code above.

Anyone can help?
I need a identity server for Node.js that works with relational databases
I am a relative newbie to node.js and typescript and am looking for tutorials and examples for building custom libraries for typescript. I am currently working on a project(switched to webstorm GUI) that requires I build several microservices and several of the microservices will need to share certain code, i.e., base repository functionality, etc. My though would be to move the code they have in common to a series of separate libraries(projects) and make them into typings and have the projects that need them to install them. Following the example I found here, and using grunt: What is the story for creating and consuming TypeScript libraries?, I was able to generate the .js file and the .d.ts files in a dist folder on the project. There are a few areas that I am confused about:

1) The example makes reference to a "main": "./dist/my.service.js" section in the jsconfig file, how necessary is this file and what should go into it?

2) If all of the files are transpiled and added to the dist folder, will the dependent code still be able to access it or do I have to transpile all of the files to root?

3) After I have have all of the file successfully transpiled and moved to the proper location, how do I install them to the dependent project if they are local and not up on the npm or Definitely Typed, etc.?
After upgrading to node.js 7.5.0, I encountered this error too:  Loading "grunt-karma.js" tasks...ERROR >> TypeError: Cannot read property 'prototype' of undefined
npm version
$ npm -v

node version
$ node -v

$ npm install -g xsl-transform
npm http GET
npm http 304
npm http GET
npm http GET
npm http 304
npm http 304

> node_xslt@0.1.9 preinstall C:\Users\TEMP.Rumba-DEV.010\AppData\Roaming\npm\node_modules\xsl-transform\node_modules\node_xslt
> node-gyp rebuild

C:\Users\TEMP.Rumba-DEV.010\AppData\Roaming\npm\node_modules\xsl-transform\node_modules\node_xslt>node "C:\Program Files\nodejs\node_modules\npm\bin\node-gyp-bin\\..\..\node_modules\node-gyp\bin\node-gyp.js" rebuild
gypnpm ERR! node_xslt@0.1.9 preinstall: `node-gyp rebuild`
npm ERR! `cmd "/c" "node-gyp rebuild"` failed with 1
npm ERR!
npm ERR! Failed at the node_xslt@0.1.9 preinstall script.
npm ERR! This is most likely a problem with the node_xslt package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     node-gyp rebuild
npm ERR! You can get their info via:
npm ERR!     npm owner ls node_xslt
npm ERR! There is likely additional logging output above.

npm ERR! System Windows_NT 6.2.9200
npm ERR! command "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "install" "-g" "xsl-transform"
npm ERR! …
I am trying to generate a pdf file from a dynamic handlebar webpage that would display data from the database. Once I get this to work on my local machine, I would like to move the code up to elastic beanstalk. The code seems to run that initially makes the call to spawn, however, call to phantomjs does not seem to kick off the script passed to it. Just to confirm, I added a console.log statement at the very beginning of the file and never the print out. Not to mention the other print statement in the script file. The code is below:

code that performs the spawn:
var childArgs = [
                  path.join(__dirname, '../phantom/capture.js'),

            let child = spawn(phantomjs.path, childArgs, {detached: false});

            console.log('set up stderr.....');
            child.stderr.on('data', (data) => {
              console.log('ps stderr: ${data}');

            console.log('set up stdout.....');
            child.stdout.on('data', (data) => {
              console.log('ps stdout: ${data}');

            console.log('set up close.....');
            child.on('close', (code) => {
                console.log('this is a test 2.....');
                if (code !== 0){
                    let error = new Error('An error occurred while creating the current report.');

Open in new window

upload.js file

module.exports.xml_node = "Abc";       

 $('.upload-btn').on('click', function (){

      $('.creatingXMLRequest').on('click', function (){

and accessing xml_node variable in app.js file

var upload_file = require('./public/javascripts/upload');        //console.log(upload_file.xml_node);

 After writing  .........module.exports.xml_node = "Abc";  ............... in upload.js file

getting this error..................................................................

$ node app.js
         $('.upload-btn').on('click', function (){
ReferenceError: $ is not defined
    at Object.<anonymous> (C:\Users\Desktop\file upload using node\public\javascripts\upload.js:8:3)
    at Module._compile (module.js:460:26)
    at Object.Module._extensions..js (module.js:478:10)
    at Module.load (module.js:355:32)
    at Function.Module._load (module.js:310:12)
    at Module.require (module.js:365:17)
    at require (module.js:384:17)
    at Object.<anonymous> (C:\Users\Desktop\file upload using node\app.js:7:19)
    at Module._compile (module.js:460:26)
    at Object.Module._extensions..js (module.js:478:10)

how to resolve it???

var http = require('http');
var util = require('util');
var fs = require('fs');
http.createServer(function (req, res) {
    console.log('Request received: ');
    //util.log(util.inspect(req)) // this line helps you inspect the request so you can see whether the data is in the url (GET) or the req body (POST)
    //util.log('Request recieved: \nmethod: ' + req.method + '\nurl: ' + req.url) // this line logs just the method and url

    res.writeHead(200, { 'Content-Type': 'text/plain' });
    req.on('data', function (chunk) {
        console.log('GOT DATA!');

console.log('Server running on port 8080');


    <script language="javascript" type="text/javascript" src="jquery-1.8.3.min.js"></script>

    response here: <p id="lblResponse">fill me in</p>

<script type="text/javascript">
$(document).ready(function() {
        url: '',
        dataType: "json",
        data: {name:'abc',name1:'pqr'},
        type: 'POST',
            contentType: "application/json",
        jsonpCallback: 'callback', // this is not relevant to the POST anymore
        success: function (data) {
            var ret = jQuery.parseJSON(data);
            console.log('Success: ')
        error: function (xhr, status, error) {
Get MySQL database support online, now!
Get MySQL database support online, now!

At Percona’s web store you can order your MySQL database support needs in minutes. No hassles, no fuss, just pick and click. Pay online with a credit card.

I am reviewing several approaches to re-developing a node.js restful monolithic application using microservices combined with an api gateway. In looking at using the aws api gateway though there seems to be a few items I have not been able to find alot of documentation on. For one, the application I am designing has to be able to support SSO, I would like users to be able to register by either creating a local login or using their current facebook, twitter, etc. social accounts.

How would this process be handled by aws api gateway, especially since I would need to use a custom database to write to and read from, not to mention to authorizing the user?

Additionally, for example, say my microservices has the following bounded contexts:

account(login, registration, profile management),

billing(may not be ideal for serverless due to running time, may opt for docker + ec2),

friend(setting up friend associations),

file(users can upload pictures and videos to their timeline - seems to be another docker + ec2 candidate);

and I want to use an api gateway to secure all of the microservice endpoints except the ones specific to login and registration, how should this be done?

Node.js contains a package that seems to handle jwt and authentication users via facebook, twitter, local, etc. called passport, can I use this with the api gateway authentication?

Also, if the api gateway is securing the microservices, how does the request object and response object get …
I created an application on my local machine(mac os x) that generates a report and saves it to a folder in my web project folder. When I deploy the app., this folder should get published as well. Granted, no one should have access to this folder but the app. When I run the code to generate the report works fine on my local machine, but it seems to hang on elastic beanstalk. What do I need to do to make this work on the elastic beanstalk environment?

In a nutshell, I am using phantomjs to convert a dynamic webpage into a pdf file that gets emailed to the appropriate parties involved. Here is the code that generates the file:

page.viewportSize = { width: 2000, height: 800 };
//page.paperSize = { format: 'Letter', orientation: 'landscape', margin: '1cm' };
page.paperSize = { width: '1280px', height: '800px', margin: '0px' };
page.settings.localToRemoteUrlAccessEnabled = true;
page.settings.loadImages = true;
page.settings.javascriptEnabled = true;"" + args[1], function start(status) {
  if (status === 'fail'){

//page.render('/dev/stdout', { format: 'pdf' });
  page.render(fs.workingDirectory + '/tmp/' + args[3], { format: 'pdf' });

Open in new window


var fs = require('fs');
var addData = " <book category='children'><title>Harry Potter</title><author>J K. Rowling</author><year>2005</year><price>29.99</price></book>";
var cursor = "//cursor";
addData += cursor;
//var ws = fs.createWriteStream('./new_xml.xml');           //creating new file in same folder.      
fs.exists("new_xml.xml", function (exists) {
    if (exists) {
        //Adding new node in existing xml file      
        fs.readFile("new_xml.xml", "utf-8", function (err, data) {
            if (err) {
            var newData = data.replace(/\/\/cursor/, addData);
            fs.writeFile("new_xml.xml", newData, function (err) {
                if (err) {
                console.log("XML node is added successfully........");
            // console.log(data);      
    } else {
        console.log("File not exists.................");


   <book category="cooking">
       <title lang="en">Everyday Italian</title>
       <author>Giada De Laurentiis</author>
       <price>30.00</price> </book>

In this example before //cursor 1 book node is added after executing node js.....(using this command node add.js).

same code executed in …
I am new to aws and have to deploy a node.js app to their elastic beanstalk technology.  I reviewed their docs. and it look like I need to upload a zip(bundle) file to install the node.js app.  I am currently using eclipse neon for development and looking for a way, whether via script or ide, to automate the process of building the bundle file on the fly.  Ideally, eclipse would do this automatically for me whenever I would like to deploy.  I am looking for information and advice what I should use to automate the bundling and publishing processes.
I am trying to convert an html file to a pdf document that will ultimately be emailed to several parties.  I am using phantomjs to render the dynamic html document to '/dev/stdout' to ultimately get attached to an email that will be sent out to multiple individuals.  The code involved in this scenario is outlined below:

//This is the capture.js file
var webPage = require('webpage');
var system = require('system');
var args = system.args;
var page = webPage.create();

if (args.length === 1) {
} else {
	page.viewportSize = { width: 600, height: 600 };
	page.paperSize = { format: 'Letter', orientation: 'portrait', margin: '1cm' };"http://localhost:3000/salesorder/" + args[1], function start(status) {
	  if (status === 'fail'){
	  page.render('/dev/stdout', { format: 'pdf' });

Open in new window

//here is the code that reads '/dev/stdout, to retrieve the generated pdf'
function(resolve, reject) {
            	var childArgs = [
            		  path.join(__dirname, '../phantomservice/capture.js'),

          		childProcess.execFile(phantomjs.path, childArgs, {maxBuffer: 1000*1024}, function(err, stdout, stderr) {
          			if (err){

Open in new window

var mailOptions = {
		    from: fromaddress, // sender address
		    to: toaddresslist, // list of receivers
		    subject: subject, // Subject line
		    html: text
		if (attachments){
			mailOptions.attachments = [
		        {   // binary buffer as an attachment
		            filename: 'invoice.pdf',
		            content: new Buffer(attachments),
		            contentType: 'application/pdf',
		            encoding: 'base64'

Open in new window

Here are the issues I am having:

1) When I send the file to stdout, I am getting a three page blank document, what could be causing this to happen and how can I fix it?
2) As an experiment, I wrote the file to a pdf file and reviewed the file.  In this case I got back the document, but I did not see the page populated with data from the database; the population occurs using jquery.
3) I am using bootstrap, and in the case where I am printing to a file; the formatting is way out of whack, it is treating the document as if it belongs on a tablet or phone because it appears to stack the document items as opposed to making them appear as they are on the webpage.  Wht can be done to fix this?  

This is a node.js app using bootstrap and currently running on my local mac os x laptop.  Any help would be greatly appreciated.
I am taking a webpage, using jquery to load the page on document.ready, css to format the page, node.js http to retrieve the page from the server, html-pdf to convert the html to a pdf file. From this point, I am sending the file as an email attachment. The ultimate goal is to create an invoice. The issue is that the css and js do not appear to be processing when it is in external files. I would prefer to keep in external files but need jquery to populate the page on document.ready and the css to properly format the page. Also, I added cheerio to the mix to see if that would make sure the processing occurred correctly and it did not help. The code is outlined below:

email sending code:
    var transporter = nodemailer.createTransport({
        service: 'gmail',
        host: this.hostname,
        auth: {
            user: this.smtpusername,
            pass: this.smtppassword

    var mailOptions = {
        from: fromaddress, // sender address
        to: toaddresslist, // list of receivers
        subject: subject, // Subject line
        html: text

    if (attachments){
        mailOptions.attachments = [
            {   // binary buffer as an attachment
                filename: 'invoice.pdf',
                content: attachments,
                contentType: 'application/pdf',
                encoding: 'base64'

html conversion code:
                let body = [];
                var options = {

Open in new window



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.

Related Topics