Nikola Brežnjak blog - Tackling software development with a dose of humor
  • Home
  • Daily Thoughts
  • Ionic
  • Stack Overflow
  • Books
  • About me
Home
Daily Thoughts
Ionic
Stack Overflow
Books
About me
  • Home
  • Daily Thoughts
  • Ionic
  • Stack Overflow
  • Books
  • About me
Nikola Brežnjak blog - Tackling software development with a dose of humor
NodeJS

Cannot start OpenDebug because Mono (or a Mono version >= 3.10.0) is required when debugging Node.js applications with free Visual Studio Code on a Mac

This error come up when I tried to use the debugging tools for Node.js program using Visual Studio Code, as outlined in their official tutorial.

The solution was quite easy actually – on a Mac all I had to do was run the following command:

brew install mono
NodeJS

Codeschool Express.js Notes

Building blocks of Express.js on CodeSchool,  notes below… If you’re interested for more in depth tutorial about Node.js and Express, make sure you check out the 2nd tutorial (free, OFC) in a MEAN series I made for HackHands named Delving into Node.js and Express web framework.

Level 1

Install Express with npm:

npm install express

Simples web server which responds with Howdy!

var express = require('express');
var app = express();

app.get('/', function(req, res){
    res.json("Howdy!");
});

app.listen(1337); //tcp port btw

Test with curl (-i switch prints the headers):

curl -i http://localhost:1337

Redirecting the requests:

res.redirect(301, '/newLink');

Level 2

Static middleware to serve files from folder public.

app.use(express.static('public'));
app.use(function(req, resp, next){
    ...some work, when done call Ghost buster, erm, no
    next();
});

Level 3

app.get('/blocks', function(request, response) {
    //request.query.limit
    //if the request was like /api?limit=10
});
app.get('/blocks/:name', function(request, response) {
    //request.params.name
});

Level 4

//npm install body-parser

var bodyParser = require('body-parser');
var parseUrlencoded = bodyParser.urlencoded({ extended: false });
//false forces the use of the native querystring Node library

app.post('/api', parseUrlencoded, function(request, response) {
var blocks = { ... };
var newBlock = request.body;
});

Level 5

app.route('/cities')
.get(function (request, response) {
})
.post(parseUrlencoded, function (request, response) {
});

Instead of

app.get('/apiEndpoint', function (request, response) {
});
app.post('/apiEndpoint', parseUrlencoded, function (request, response) {
});

Using the router to put in different file:

var router = express.Router();

router.route('/', router)
  .get(function (request, response) {
  })
  .post(parseUrlencoded, function (request, response) {
  });

router.route('/:name', router)
  .get(function (request, response) {
  })
  .delete(function (request, response) {
  });

app.use('/cities', router);
NodeJS, Quick tips

Keep your Node.js scripts running with Forever and Nodemon

edit (18.06.2015): Nowdays I’m using PM2, and here’s my post that explains how to use PM2.


Nodemon is a utility that will monitor for any changes in your source and automatically restart your server.  Install with npm:

npm install -g nodemon

Forever is a simple CLI tool for ensuring that a given script runs continuously (i.e. forever). Install with npm:

npm install -g forever

Forever & Nodemon running together:

forever start nodemon --exitcrash app.js

edit (24.02.2015):

If you get an error like this:

error:   Cannot start forever
error:   script /home/nikola/nodemon does not exist.

Try to run nodemon with the full path:

forever start /usr/bin/nodemon --exitcrash app.js

You can find out the path to nodemon by executing:

which nodemon
NodeJS

How to use Redis with Node.js

Redis is an open source, BSD licensed, advanced key-value cache and store. It is often referred to as a data structure server since keys can contain strings, hashes, lists, sets, sorted sets, bitmaps and hyperloglogs.

Comparison with Memcache and Memcached can be found here, and the naming distinction can be found here.

You can download the installation zip file here (I used the Windows version), and extract it to C:\redis. To run the Redis server (in order to be able to save to it and query it) you have to execute the redis-server.exe from this directory.

To use Redis with Node.js you have install the redis module:

npm install redis

A simple usage example:

var redis = require("redis"),
    client = redis.createClient();

// if you'd like to select database 3, instead of 0 (default), call
// client.select(3, function() { /* ... */ });

client.on("error", function (err) {
    console.log("Error " + err);
});

client.set("string key", "string val", redis.print);
client.hset("hash key", "hashtest 1", "some value", redis.print);
client.hset(["hash key", "hashtest 2", "some other value"], redis.print);
client.hkeys("hash key", function (err, replies) {
    console.log(replies.length + " replies:");
    replies.forEach(function (reply, i) {
        console.log("    " + i + ": " + reply);
    });
    client.quit();
});

A lot more examples here.

CodeProject, NodeJS

How I built my own testable The Answer To Life The Universe And Everything npm module

TL;DR: In this short tutorial I’ll show you how I built my own testable (Jasmine) npm module which I then published to npm repository. The npm module is here, and the GitHub repository is here.

First, if you haven’t already, set some author info in your terminal:

npm set init.author.name "Nikola Brežnjak"
npm set init.author.email "[email protected]"
npm set init.author.url “http://www.nikola-breznjak.com"

Then, create a new GitHub repository, clone it to your disk and then run npm init. Create a index.js file and copy/paste the following code:

module.exports = function(){
    return 42;
}

Next, install Jasmine by doing:

npm install jasmine-node -g

To test your module, create a folder spec, and a file TheAnswerToLifeTheUniverseAndEverything.spec.js inside it with the following content:

var TheAnswerToLifeTheUniverseAndEverything = require('../index.js');

describe("TheAnswerToLifeTheUniverseAndEverything Suite", function() {
 it("should return a value of 42", function(done) {
 var value = TheAnswerToLifeTheUniverseAndEverything();
 expect(value).toEqual(42);
 done();
 });
});

In order to test your module, run jasmine-node spec/ as shown on the image below:

jasmineTest

In order to publish your npm module you first have to execute the npm adduser command and answer few of the questions, and after that you just have to execute npm publish and you’ll have your npm module listed on npmjs.com:

theAnswerToLifeNPMmodule

Now you can use npm install theanswertolifetheuniverseandeverything to install the module.

If you’re testing this your self and you get an error like “Error: forbidden New packages must have all-lowercase names: TheAnswerToLifeTheUniverseAndEverything” then that means what it says – you must use only lowercase letters when naming your modules.

NodeJS, Servers

How to host multiple Node.js applications with multiple different domains on one VPS with Nginx

First things first, if you bought your domain elsewhere then you first need to point that domain to your server. You basically have two options here

  • installing, setting up and running a DNS on your VPS and pointing the DNS (from the control panel where you bought a domain) records to your VPS
  • setting your DNS Zone file A record (in the control panel where you bought a domain) to the VPS IP
  • this posts explain what are the pros and cons

Now, if you do that for multiple domains they will all point to your server’s IP and show the same thing, essentially the thing which is running on port 80 (and that, in our main Nginx installation, will be a default Nginx welcome screen). If you have multiple Node.js applications, which are running on different ports, and you want to pinpoint the domains to that particular applications, then this is where the Nginx comes in so that it takes the requests for each domain and routes it to an appropriate port where the appropriate Node.js application is running. Basically, what Nginx does in this case is called reverse proxying.

Useful links:

  • this StackOverflow question
  • http://blog.grabeh.net/Digital-Ocean-VPS-Nginx-Express-apps
  • https://www.digitalocean.com/community/tutorials/how-to-host-multiple-node-js-applications-on-a-single-vps-with-nginx-forever-and-crontab
  • http://ludovf.net/blog/configure-nginx-to-proxy-virtual-hosts-to-apache/
  • http://kbeezie.com/apache-with-nginx/
  • https://www.digitalocean.com/community/tutorials/how-to-set-up-nginx-virtual-hosts-server-blocks-on-centos-6

Use forever:

  • npm install forever -g
  • forever start –spinSleepTime 10000 yourApp.js
  • if the app crashes, forever starts it up again

Lets start:

  • sudo vim /etc/nginx/conf.d/example.com.conf:
    server {
        listen 80;
    
        server_name your-domain.com;
    
        location / {
            proxy_pass http://localhost:{YOUR_PORT};
            proxy_http_version 1.1;
            proxy_set_header Upgrade $http_upgrade;
            proxy_set_header Connection 'upgrade';
            proxy_set_header Host $host;
            proxy_cache_bypass $http_upgrade;
        }
    }
  • to reference multiple domains for one Node.js app (like www.example.com and example.com) you need to add the following code to the file /etc/nginx/nginx.conf in the http section: server_names_hash_bucket_size 64;
  • but, as it always is, the upper statement didn’t work for me, so I ended up using this solution from StackOverflow:
    server {
        #listen 80 is default
        server_name www.example.com;
        return 301 $scheme://example.com$request_uri;
    }
  • sudo service nginx restart

Forever keeps your application running when it crashes but if VPS is rebooted it won’t start anymore. Simple cronjob solves this issue. Create starter.sh in your application’s home folder and copy the following code:

#!/bin/sh

if [ $(ps -e -o uid,cmd | grep $UID | grep node | grep -v grep | wc -l | tr -s "\n") -eq 0 ]
then
export PATH=/usr/local/bin:$PATH
forever start --sourceDir /path/to/your/node/app main.js >> /path/to/log.txt 2>&1
fi

where main.js is your application’s main script. Add to crontab the following line: @reboot /path/to/starter.sh.

NodeJS

How to get all of your own Facebook posts and parse them with JavaScript

So, first you need to download all the data that Facebook has stored for you (well, and what it’s willing to give you :)). You can do that by going to https://www.facebook.com/settings when you’re logged in, and you will see the following screen:FacebookDataDownload2

Here you can just click on the Download a copy of your Facebook data and after they process your request you will get the download link on your email.

The download package looks contains 3 folders (videos, photos, html) and a index.html file. In order to take a look at your posts you have to open up the html folder where you’ll find the file named wall.htm. This is a simple HTML file whose contents is put inside the <div class=”comment”> elements.

In order to parse this with JavaScript (you’ll need to have Node.js installed) you can use the following snippet:

function getMatches(string, regex, index) {
    index || (index = 1); // default to the first capturing group
    var matches = [];
    var match;
    while (match = regex.exec(string)) {
        matches.push(match[index]);
    }
    return matches;
}

fs = require('fs');
fs.readFile('wall.htm', 'utf8', function(err, data){
	if (err){
	    return console.log(err);
	}

	var regex = /comment">([\s\S]*?)<\/div>/g
	var matches = getMatches(data, regex, 1);

	var output = '';
	for(var i=0; i<matches.length; i++){
		output += matches[i] + '\n';
	}

	fs.writeFile('parsed.txt', output, 'utf8', function(){
		console.log('done!');
	});
});

What this does is that it reads the wall.html file and outputs just simple text of the posts in a parsed.txt file.

Few of the challenges here we’re the multiline regex matching which I solved with this link on StackOverflow, and another one was getting access to matched groups of a regex in JavaScript.

NodeJS, Quick tips

How to delete node_modules folder on Windows machine?

Due to its folder nesting Windows can’t delete the folder as its name is too long. To solve this, install RimRaf:

npm install rimraf -g

and delete the node_modules folder easily with:

rimraf node_modules

 

edit: If you happen to get an “error” like this:

C:\Users\Nikola\Desktop>npm install -g rimraf
C:\Users\Nikola\AppData\Roaming\npm\rimraf -> C:\Users\Nikola\AppData\Roaming\npm\node_modules\rimraf\bin.js
npm WARN unmet dependency C:\Users\Nikola\AppData\Roaming\npm\node_modules\generator-ionic requires cordova@'^4.2.0' but will load
npm WARN unmet dependency C:\Users\Nikola\AppData\Roaming\npm\node_modules\cordova,
npm WARN unmet dependency which is version 5.1.1
npm WARN unmet dependency C:\Users\Nikola\AppData\Roaming\npm\node_modules\bower\node_modules\bower-registry-client requires request@'~2.51.0' but will load
npm WARN unmet dependency undefined,
npm WARN unmet dependency which is version undefined
npm WARN unmet dependency C:\Users\Nikola\AppData\Roaming\npm\node_modules\bower\node_modules\fstream-ignore requires fstream@'^1.0.0' but will load
npm WARN unmet dependency undefined,
npm WARN unmet dependency which is version undefined
npm ERR! peerinvalid The package node-inspector does not satisfy its siblings' peerDependencies requirements!
npm ERR! peerinvalid Peer [email protected] wants node-inspector@~0.7.0

npm ERR! System Windows_NT 6.1.7601
npm ERR! command "C:\\NodeJS\\\\node.exe" "C:\\NodeJS\\node_modules\\npm\\bin\\npm-cli.js" "install" "-g" "rimraf"
npm ERR! cwd C:\Users\Nikola\Desktop
npm ERR! node -v v0.10.36
npm ERR! npm -v 1.4.28
npm ERR! code EPEERINVALID
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR!     C:\Users\Nikola\Desktop\npm-debug.log
npm ERR! not ok code 0

Don’t panic :), just try to run rimraf instead, as noted above. In most cases, all will be okay and you’ll be able to use it without a problem. If not, head to the comments, and we’ll take care of it together! For those who don’t care much about comments, here’s the post in which I address this node-inspector issue.

How to delete node_modules folder on Windows machine? http://t.co/0pV4OSTG1L #nodejs #windows #node_modules

— Nikola Brežnjak (@HitmanHR) July 28, 2015

NodeJS

MEAN.io VS MEAN.js and deploying the latter on DigitalOcean

What are they?

MEAN.(io + js) are both full-stack JavaScript frameworks, and they are both comprised of these technologies:

  • MongoDB – leading NoSQL database, empowering businesses to be more agile and scalable
  • Express – minimal and flexible Node.js web application framework, providing a robust set of features for building single and multi-page, and hybrid web applications
  • Angular – lets you extend HTML vocabulary for your application. The resulting environment is extraordinarily expressive, readable, and quick to develop
  • Node.js – a platform built on Chrome’s JavaScript runtime for easily building fast, scalable network applications

Which is which?

There seems to be a lot of confusion between the two, and this StackOverflow answer can help clarify it. Essentially:

Mean.js is a fork of Mean.io and both initiatives were started by the same guy. Mean.io is now under the umbrella of the company Linnovate and looks like the guy (Amos Haviv) stopped his collaboration with this company and started Mean.js. You can read more about his reasons here.

On their GitHub pages the MEAN.io has more stars, forks, and watchers but that may easily be to the fact that the MEAN.js is younger:

mean js github page

MEAN.js GitHub page

mean.io github page

MEAN.io GitHub page

How to get started?

I already wrote about MEAN.io and how to deploy it to Nodejitsu from Windows machine, and in this blog post I’ll show you how easy it is to deploy MEAN.js on DigitalOcean. Surely, you can deploy MEAN.io too on DigitalOcean, but you would have to install all the prerequisites on your own, and as you’ll see the MEAN.js is all set up automagically with few button clicks.

Disclamer: I am affiliated with DigitalOcean. If the post helped you, you can signup via my referral link. They regularly offer free credit (currently they offer 10$) so you can try it out without paying anything (I’m sure you have the Google skills to get the discount code).

So, from my experience with the cloud hostings I was pretty much amazed how fast you can get your root box up and running on DigitalOcean, additionally they have the (so called) droplet for MEAN ready so in basically less than 1 minute you’ll have everything ready to start coding your MEAN project. Let’s now see how to do this step by step.

Create a droplet

Naturally, first you have to signup up with DigitalOcean (remember to look for coupons), and once you do that you’ll be able to login to their web admin dashboard.

DigitalOcean calls its virtual servers, droplets; each droplet that you create is a new virtual server for your personal use. In order to create a new droplet from your web admin, click on the CREATE button, and select a custom hostname and size (as shown on the image below):

create_1

All on the same page (scroll down), select a region which is closest to you (London  1 in my case, as shown on the image below):

create_2

The most important part is selecting the actual distribution/application that will be installed on your droplet by default. Here you have quite a few options and I encourage you to test them as you see fit. In my example, however, we’re gonna use the MEAN on Ubuntu 14.04 (as shown on the image below).

create_4

Finally, you can leave the additional settings as they are and you can confirm the droplet creation by clicking on the Create Droplet button.

create_5

Login to your new droplet

Shortly after (less than 1 minute!) you’ve clicked the Create Droplet button you’ll get the email with the info on how to connect to your droplet. Below is the example of such an email. In order to connect to your droplet you can use PuTTY (a free implementation of Telnet and SSH for Windows and Unix platforms), and all you’ll have to do is enter the IP and click Open (it’s good to name this connection and save it for later use – digocean in the image below).connect_1

If the popup appears as shown on the image below, most likely you’ll want to click Yes.connect_2

When you log in with the username root and password that you got in the mail, you’ll be prompted to repeat the root’s password and to change it to something else, which is a standard security practice.connect_3

Run the application

Your application will be located in /opt/mean  folder, and in order to run it you just have to execute the following command in that folder:

grunt

Output that you’ll most likely see after running the grunt command can be seen on the image below:

run_1

To view your application in the browser, visit http://YOUR_DROPLET_IP:3000/ (in my case that would be http://178.62.47.198:3000) and you should see a screen similar to the one on the image below:run_2Finally, all done. Next logical step would be to check out he MEAN.js docs.

Happy building!

CodeProject, NodeJS

Deploying MEAN.io to Nodejitsu from Windows machine

Disclaimer: I’m in no way affiliated with Nodejitsu or MEAN.io. I’m just documenting my experience with them – problems (and solutions) I’ve faced while trying these new technologies on a Windows machine.

Great, with that off my chest, we can now start. This is a successor post to the previous one: Getting started with Nodejitsu on Windows by deploying a MEN framework, so you may wanna check that too.

MEAN is a fullstack javascript platform for modern web applications.

MongoDB – leading NoSQL database, empowering businesses to be more agile and scalable

Express – minimal and flexible node.js web application framework, providing a robust set of features for building single and multi-page, and hybrid web applications

Angular – lets you extend HTML vocabulary for your application. The resulting environment is extraordinarily expressive, readable, and quick to develop

Node.js – a platform built on Chrome’s JavaScript runtime for easily building fast, scalable network applications

Following the notes on the official website you have to clone the repo, install all the dependencies withnpm  and then run grunt .

git clone http://github.com/linnovate/mean.git

cd mean

npm install

grunt

If you get an error like this:

C:\Users\Nikola\Desktop\mean>grunt
Running "jshint:all" (jshint) task
>> 42 files lint free.

Running "concurrent:tasks" (concurrent) task
Running "nodemon:dev" (nodemon) task
Running "watch" task
Waiting...[nodemon] v1.0.15
[nodemon] to restart at any time, enter `rs`
[nodemon] watching: *.*
[nodemon] starting `node --debug server.js`
debugger listening on port 5858
Express app started on port 3000

events.js:72
        throw er; // Unhandled 'error' event
              ^
Error: failed to connect to [localhost:27017]
    at null.<anonymous> (C:\Users\Nikola\Desktop\mean\node_modules\mongoose\node
_modules\mongodb\lib\mongodb\connection\server.js:553:74)
    at EventEmitter.emit (events.js:106:17)
    at null.<anonymous> (C:\Users\Nikola\Desktop\mean\node_modules\mongoose\node
_modules\mongodb\lib\mongodb\connection\connection_pool.js:140:15)
    at EventEmitter.emit (events.js:98:17)
    at Socket.<anonymous> (C:\Users\Nikola\Desktop\mean\node_modules\mongoose\no
de_modules\mongodb\lib\mongodb\connection\connection.js:512:10)
    at Socket.EventEmitter.emit (events.js:95:17)
    at net.js:440:14
    at process._tickCallback (node.js:415:13)
[nodemon] app crashed - waiting for file changes before starting...

make sure that you have MongoDB installed and that you have the mongod.exe running on the default port 27017. Instructions on how to install MongoDB on a Windows machine can be found here: http://docs.mongodb.org/manual/tutorial/install-mongodb-on-windows/, but tl;dr is:

  • download the installation zip package
  • unzip in c:\mongodb
  • create c:\data\db  folder
  • run c:\mongodb\bin\mongod.exe

When you have mongod.exe  started in one command window (I use Console2) and you run grunt  in other you will get this in the “mongo” console:

C:\mongodb\bin>mongod.exe
mongod.exe --help for help and startup options
Tue Mar 11 14:50:24.240 [initandlisten] MongoDB starting : pid=10136 port=27017 dbpath=\data\db\ 64-bit host=Nikola-PC
Tue Mar 11 14:50:24.240 [initandlisten] db version v2.4.9
Tue Mar 11 14:50:24.240 [initandlisten] git version: 52fe0d21959e32a5bdbecdc62057db386e4e029c
Tue Mar 11 14:50:24.240 [initandlisten] build info: windows sys.getwindowsversion(major=6, minor=1, build=7601, platform=2, service_pack='Service Pack 1') BOOST_LIB_VERSION=1_49
Tue Mar 11 14:50:24.240 [initandlisten] allocator: system
Tue Mar 11 14:50:24.240 [initandlisten] options: {}
Tue Mar 11 14:50:24.244 [initandlisten] journal dir=\data\db\journal
Tue Mar 11 14:50:24.244 [initandlisten] recover : no journal files present, no recovery needed
Tue Mar 11 14:50:24.323 [initandlisten] waiting for connections on port 27017
Tue Mar 11 14:50:24.324 [websvr] admin web console waiting for connections on port 28017
Tue Mar 11 14:50:40.982 [initandlisten] connection accepted from 127.0.0.1:58323 #1 (1 connection now open)
Tue Mar 11 14:50:41.014 [initandlisten] connection accepted from 127.0.0.1:58324 #2 (2 connections now open)
Tue Mar 11 14:50:41.024 [initandlisten] connection accepted from 127.0.0.1:58325 #3 (3 connections now open)
Tue Mar 11 14:50:41.024 [initandlisten] connection accepted from 127.0.0.1:58326 #4 (4 connections now open)
Tue Mar 11 14:50:41.025 [initandlisten] connection accepted from 127.0.0.1:58327 #5 (5 connections now open)

and this in the “grunt” console:

C:\Users\Nikola\Desktop\mean>grunt
Running "jshint:all" (jshint) task
>> 42 files lint free.

Running "concurrent:tasks" (concurrent) task
Running "nodemon:dev" (nodemon) task
Running "watch" task
Waiting...[nodemon] v1.0.15
[nodemon] to restart at any time, enter `rs`
[nodemon] watching: *.*
[nodemon] starting `node --debug server.js`
debugger listening on port 5858
Express app started on port 3000

You can now take a look at your application by visiting localhost:3000 in your browser: meanHomeView the signup screen: meanSignup and signin screen: meanSignin

Ship it

In order to deploy to Nodejitsu, you have to login to Nodejitsu (jitsu login ) and then run jitsu deploy . At this point I got an error like this:

info:    Starting app mean
error:   Error running command deploy
error:   Errors occured while starting the application
error:   Error output from application. This is usually a user error.
error:   grunt-cli: The grunt command line interface. (v0.1.13)
error:
error:   Fatal error: Unable to find local grunt.
error:
error:   If you're seeing this message, either a Gruntfile wasn't found or grunt
error:   hasn't been installed locally to your project. For more information about
error:   installing and configuring grunt, please see the Getting Started guide:
error:
error:   http://gruntjs.com/getting-started
error:
error:   Error starting application. This could be a user error.
error:   info: Running start for app.
error:   info: Cleaning /opt/run
error:   info: Fetching application snapshot...
error:   info: Application snapshot fetched.
error:   info: Unpacking snapshot...
error:   info: Reading `package.json`...
error:   info: Starting application...
error:   info: Spawn: start --min-uptime 2000 -o /opt/run/forza.log -- forza -h multiplex.nodejitsu.com -p 8556 --start-log /opt/run/start.log --app-user hitman666 --app-name mean -- node node_modules/grunt-cli/bin/grunt
error:   info: `aeternum` pid: 63258
error:   info: Writing pidfile: /root/app.pid
error:   info: Tailing forza log: /opt/run/start.log
error:   info: Tail closing..
error:   info: Retry # 1 with 1000ms interval
error:   info: Tailing forza log: /opt/run/start.log
error:   info: Tail closing..
error:   info: Success:start

and naturally, I went looking if someone had a similar issue and it turns out someone on Stackoverflow asked this question. The OP (original poster) did find a solution him self and he said:

The gist of it was I had to move all grunt, karma, and forever dependencies to my devDependencies in the package.json file and change my start to “node server”.

Now, I tried to communicate with the OP to get some more info, but strangely no reply (yet). I figured it out myself in the end and this is how my package.json  file looks like now:

{
  "name": "mean",
  "description": "MEAN - A fullStack javascript framework powered by  MongoDB, ExpressJS, AngularJS, NodeJS.",
  "version": "0.1.2-1",
  "private": false,
  "repository": {
    "type": "git",
    "url": "https://github.com/linnovate/mean.git"
  },
  "engines": {
    "node": "0.10.x",
    "npm": "1.3.x"
  },
  "scripts": {
    "start": "node server.js",
    "test": "node node_modules/grunt-cli/bin/grunt test",
    "postinstall": "node node_modules/bower/bin/bower install"
  },
  "dependencies": {
    "express": "~3.4.7",
    "bower": "~1.2.8",
    "grunt-cli": "~0.1.11",
    "connect-mongo": "~0.4.0",
    "connect-flash": "~0.1.1",
    "consolidate": "~0.10.0",
    "swig": "~1.3.2",
    "mongoose": "~3.8.3",
    "passport": "~0.1.18",
    "passport-local": "~0.1.6",
    "passport-facebook": "~1.0.2",
    "passport-twitter": "~1.0.2",
    "passport-github": "~0.1.5",
    "passport-google-oauth": "~0.1.5",
    "passport-linkedin": "~0.1.3",
    "lodash": "~2.4.1",
    "forever": "~0.10.11",
    "view-helpers": "~0.1.4",
    "mean-logger": "0.0.1"
  },
  "devDependencies": {
    "grunt-env": "~0.4.1",
    "grunt-cli": "~0.1.11",
    "grunt-contrib-watch": "latest",
    "grunt-contrib-jshint": "latest",
    "grunt-karma": "~0.6.2",
    "grunt-nodemon": "0.2.0",
    "grunt-concurrent": "latest",
    "grunt-mocha-test": "latest",
    "karma": "~0.10.4",
    "karma-coffee-preprocessor": "~0.1.0",
    "karma-coverage": "~0.1.0",
    "karma-script-launcher": "~0.1.0",
    "karma-chrome-launcher": "~0.1.0",
    "karma-firefox-launcher": "~0.1.0",
    "karma-html2js-preprocessor": "~0.1.0",
    "karma-jasmine": "~0.1.3",
    "karma-requirejs": "~0.2.0",
    "karma-phantomjs-launcher": "~0.1.0",
    "forever": "~0.10.11",
    "supertest": "0.8.2",
    "should": "2.1.1"
  },
  "subdomain": "hitman666-mean2"
}

After making this change I deployed my application once more, and everything went without an error, but when I browsed it on Nodejitsu I got an error

502 Reached max retries limit

I realized that I don’t have a correct MongoDB connection string, and in order to change this I had to edit the file production.js which is in the config/env/  folder.MongoDBconnectionString

I copied the MongoDB connection string from Nodejitsu’s admin dashboard (I wrote about how to set this in my previous post: Getting started with Nodejitsu on Windows by deploying a MEN framework).

After this change I deployed my app again, and now everything was working, yay!

Page 2 of 3«123»

Recent posts

  • Discipline is also a talent
  • Play for the fun of it
  • The importance of failing
  • A fresh start
  • Perseverance

Categories

  • Android (3)
  • Books (114)
    • Programming (22)
  • CodeProject (35)
  • Daily Thoughts (77)
  • Go (3)
  • iOS (5)
  • JavaScript (127)
    • Angular (4)
    • Angular 2 (3)
    • Ionic (61)
    • Ionic2 (2)
    • Ionic3 (8)
    • MEAN (3)
    • NodeJS (27)
    • Phaser (1)
    • React (1)
    • Three.js (1)
    • Vue.js (2)
  • Leadership (1)
  • Meetups (8)
  • Miscellaneou$ (77)
    • Breaking News (8)
    • CodeSchool (2)
    • Hacker Games (3)
    • Pluralsight (7)
    • Projects (2)
    • Sublime Text (2)
  • PHP (6)
  • Quick tips (40)
  • Servers (8)
    • Heroku (1)
    • Linux (3)
  • Stack Overflow (81)
  • Unity3D (9)
  • Windows (8)
    • C# (2)
    • WPF (3)
  • Wordpress (2)

"There's no short-term solution for a long-term result." ~ Greg Plitt

"Everything around you that you call life was made up by people that were no smarter than you." ~ S. Jobs

"Hard work beats talent when talent doesn't work hard." ~ Tim Notke

© since 2016 - Nikola Brežnjak