Category Archives: NodeJS

OSX Global NPM Module command not found

In case you ended up in a situation where you just installed a global NPM module, but it still throws command not found, here’s what you have to do: Find out where the global NPM modules are installed by running: Double check that your $PATH does not already contain that value: If the value is Continue Reading »

Node n permission denied without sudo

Each time I do a fresh install of the Node Version Management tj/n I end up getting the permission denied when running npm install. If you also ran into this issue, well, there’s a quick fix. The issue is caused by the Node Version Management for which the owner is the root. The two following Continue Reading »

NPM module command not found

Until you properly config your environment you’ll probably run into the command not found error when trying to run globally installed NPM modules. Solution for Linux and OSX: Step 1 – check if the path is correct You need to have /users/<ME>/.npm-global/bin in your $PATH If the printed string doesn’t contain the above path, continue Continue Reading »

How to generate X-WSSE Token using NodeJS

Learn how to generate X-WSSE Token and how to authorize requests using X-WSSE header authentication. If you’re not familiar with X-WSSE Token Authentication and why you should use it, go ahead and read this article that contains the basics of this type of authentication. In this article I’ll describe how to generate a X-WSSE Token Continue Reading »

What is X-WSSE Token Authentication and how does it work

Learn the basics of X-WSSE Token Authentication and how to authorize requests using X-WSSE header authentication. X-WSSE Token Authentication can be used to authenticate backend-to-backend integrations using client_id and client_secret properties. The main benefit of this type of authentication is that the client_secret value never leaves the backend of the integrating client, and that each Continue Reading »

Convert seconds to Days, Hours, Minutes, Seconds

Learn how to convert number of seconds into days, minutes, hours and seconds. That’s it. You can now create a countdown timer, display the difference between two dates or just print  the time until something great happens. You now have 4 variables with values as follows: Bonus! Learn how to pad the values with 0 Continue Reading »

Socket.IO AngularJS Wrapper

I’ve been playing around with Socket.IO and AngularJS. To make things easier I created this service which can be used for transferring data between the client (which could be a web page) and a NodeJS server. The app is served by NodeJS so the Socket.IO server is listening on same location. ‘use strict’; angular .module(‘APP’) Continue Reading »

NodeJS AES256 Encryption/Decryption

In one of my projects I needed to encrypt some data. I decided to use AES256 symmetrical encryption algorithm. So this is what I’ve come to (aes_encryption.js): var crypto = require(‘crypto’), cipher_seed = ‘some_random_characters’; var encrypt = function(text) { var cipher = crypto.createCipher(‘aes-256-cbc’, cipher_seed), crypted = cipher.update(text, ‘utf8’, ‘hex’); crypted += cipher.final(‘hex’); return crypted; }; Continue Reading »