NPM Boilerplate – A Good Starting Point

NPM Boilerplate – A good starting point for your new Node.js NPM packages. A skeleton project which has everything you need for creating a new NPM package. I’m looking to enhance this template so all forks and PR’s much appreciated. View on GitHub     View on NPM Create your own NPM Package Just clone …

NODEJS “CORS Errors”

NodeJS can be configured to use CORS as means of communicating from the front-end. This can be configured in your app.js as middleware for the popular Express package. CORS errors look something like this: Both servers are running on different ports. Remember that different port consists as a cross domain request. localhost:8080 is a different …

Mongodb New Developer Q & A

Some questions about mongodb which I set about trying to find answers to before I started using it for a big project. Hopefully to help you get to know mongodb better to see if it suits your needs. MongoDB uses BSON documents to store data. What is BSON? “BSON is a binary-encoded serialization of JSON-like …

Nodejs HowTo detect OS version

Create a script to detect OS var async_exec = require(’child_process’).exec async_exec(’npm install shelljs’, function (err, stdout, stderr) {   require(’shelljs/global’);   var os = require(’os’);   echo(’Testing OS environment’);   /*     What platform you’re running on: ‘darwin’, ‘freebsd’, ‘linux’, ‘sunos’ or ‘win32’     win32 (for 32 or 64 bit)   */   …

Nodejitsu Deploy Private Github Repo Error

nodejitsu Error 502 deploy:github:no_pkg_json I’m trying to auto deploy my nodejs application from github to nodejitsu. I have already setup my webhook to nodejitsu and everything works fine when the github repository is public. Now I have made my github repo private i’m seeing an error when i commit changes. Nodejitsu emails me the error: …

Setting NODE_PATH on Windows

If your getting errors like ‘cannot find module x’ when trying to start a nodejs server on windows then you probably have some code which is looking for node modules but they are not being found. This could be a number of reasons but node will look in the default folders for the module and …

npm install error

I have no idea why the install of npm is failing. There is nothing online about this error so here it is. “AgentSSL.prototype.addRequest” -> “TypeError: Cannot read property ‘prototype’ of undefined”. I’ve tried to install npm using the following with no luck (as suggested). curl https://npmjs.org/install.sh | sh curl https://npmjs.org/install.sh | sudo sh git clone …

Node.js Get the Curent URL and Params

In your server code use the following to display the current URL and params. // API / GET exports.get = function( req, res ) {      var fullUrl = req.protocol + ‘://’ + req.get(’host’) + req.originalUrl;      res.send(fullUrl);      return true; } Or you can display the headers of the request like …

NODEJS COMMAND Shorthands

Official NODEJS COMMAND Shorthands. I found these when taking a look at the utils source code. Lovin the -gangsta one haha! exports . shorthands =    { s : [ "–loglevel" , "silent" ]    , d : [ "–loglevel" , "info" ]    , dd : [ "–loglevel" , "verbose" ]    , ddd …

cannot find module ‘jsdom’

An error I came across when trying to install jsdom npm package on my windows machine. “cannot find module ‘jsdom’. Solutions: 1. Follow instructions on this blog post to get jsdom working on windows. http://www.steveworkman.com/node-js/2012/installing-jsdom-on-windows/ 2. Use an alternative (lighter) package called Cheerio. Notes: Something I ran into was this error when using cheerio. “cheerio …

Node.js Silence Middleware Output When Testing

So I wanted to have the console output of my tests clean and not polluted by node app middleware output, such as that output by request modules when performing http requests. I remember briefly touching on this subject before when Silencing Log Output when testing. This is what the output looks like when I run …