{"id":308,"date":"2014-03-20T12:19:14","date_gmt":"2014-03-20T12:19:14","guid":{"rendered":"http:\/\/nikola-breznjak.com\/blog\/?p=308"},"modified":"2015-08-10T07:08:28","modified_gmt":"2015-08-10T07:08:28","slug":"deploying-mean-io-to-nodejitsu-from-windows-machine","status":"publish","type":"post","link":"https:\/\/nikola-breznjak.com\/blog\/javascript\/nodejs\/deploying-mean-io-to-nodejitsu-from-windows-machine\/","title":{"rendered":"Deploying MEAN.io to Nodejitsu from Windows machine"},"content":{"rendered":"<p>Disclaimer: I&#8217;m in no way affiliated with Nodejitsu or MEAN.io. I&#8217;m just documenting my experience with them &#8211; problems (and solutions) I&#8217;ve faced while trying these new technologies on a Windows machine.<\/p>\n<p>Great, with that off my chest, we can now start. This is a successor post to the previous one: <a href=\"http:\/\/nikola-breznjak.com\/blog\/nodejs\/getting-started-with-nodejitsu-on-windows-by-deploying-a-men-framework\/\">Getting started with Nodejitsu on Windows by deploying a MEN framework<\/a>, so you may wanna check that too.<\/p>\n<blockquote><p><a href=\"http:\/\/www.mean.io\/\">MEAN <\/a>is\u00a0a fullstack javascript platform for modern web applications.<\/p>\n<address><strong>M<\/strong>ongoDB &#8211; leading NoSQL database, empowering businesses to be more agile and scalable<\/address>\n<p><strong>E<\/strong>xpress &#8211;\u00a0minimal and flexible node.js web application framework, providing a robust set of features for building single and multi-page, and hybrid web applications<\/p>\n<p><strong>A<\/strong>ngular &#8211; lets you extend HTML vocabulary for your application. The resulting environment is extraordinarily expressive, readable, and quick to develop<\/p>\n<p><strong>N<\/strong>ode.js &#8211;\u00a0a platform built on Chrome&#8217;s JavaScript runtime for easily building fast, scalable network applications<\/p><\/blockquote>\n<p>Following the notes on the official website you have to clone the repo, install all the dependencies with<span class=\"lang:default decode:true  crayon-inline\">npm<\/span>\u00a0 and then run <span class=\"lang:default decode:true  crayon-inline\">grunt<\/span>\u00a0.<\/p>\n<pre class=\"lang:default decode:true\">git clone http:\/\/github.com\/linnovate\/mean.git\r\n\r\ncd mean\r\n\r\nnpm install\r\n\r\ngrunt<\/pre>\n<p>If you get an error like this:<\/p>\n<pre class=\"lang:default decode:true\">C:\\Users\\Nikola\\Desktop\\mean&gt;grunt\r\nRunning \"jshint:all\" (jshint) task\r\n&gt;&gt; 42 files lint free.\r\n\r\nRunning \"concurrent:tasks\" (concurrent) task\r\nRunning \"nodemon:dev\" (nodemon) task\r\nRunning \"watch\" task\r\nWaiting...[nodemon] v1.0.15\r\n[nodemon] to restart at any time, enter `rs`\r\n[nodemon] watching: *.*\r\n[nodemon] starting `node --debug server.js`\r\ndebugger listening on port 5858\r\nExpress app started on port 3000\r\n\r\nevents.js:72\r\n        throw er; \/\/ Unhandled 'error' event\r\n              ^\r\nError: failed to connect to [localhost:27017]\r\n    at null.&lt;anonymous&gt; (C:\\Users\\Nikola\\Desktop\\mean\\node_modules\\mongoose\\node\r\n_modules\\mongodb\\lib\\mongodb\\connection\\server.js:553:74)\r\n    at EventEmitter.emit (events.js:106:17)\r\n    at null.&lt;anonymous&gt; (C:\\Users\\Nikola\\Desktop\\mean\\node_modules\\mongoose\\node\r\n_modules\\mongodb\\lib\\mongodb\\connection\\connection_pool.js:140:15)\r\n    at EventEmitter.emit (events.js:98:17)\r\n    at Socket.&lt;anonymous&gt; (C:\\Users\\Nikola\\Desktop\\mean\\node_modules\\mongoose\\no\r\nde_modules\\mongodb\\lib\\mongodb\\connection\\connection.js:512:10)\r\n    at Socket.EventEmitter.emit (events.js:95:17)\r\n    at net.js:440:14\r\n    at process._tickCallback (node.js:415:13)\r\n[nodemon] app crashed - waiting for file changes before starting...<\/pre>\n<p>make sure that you have MongoDB installed and that you have the mongod.exe running on the default port <strong>27017<\/strong>. Instructions on how to install MongoDB on a Windows machine can be found here:\u00a0<a href=\"http:\/\/docs.mongodb.org\/manual\/tutorial\/install-mongodb-on-windows\/\">http:\/\/docs.mongodb.org\/manual\/tutorial\/install-mongodb-on-windows\/<\/a>, but\u00a0<span style=\"line-height: 1.5;\"><strong>tl;dr<\/strong> is: <\/span><\/p>\n<ul>\n<li>download the installation zip package<\/li>\n<li>unzip in <span class=\"lang:default decode:true  crayon-inline\">c:\\mongodb<\/span><\/li>\n<li>create\u00a0<span class=\"lang:default decode:true  crayon-inline \">c:\\data\\db<\/span>\u00a0\u00a0folder<\/li>\n<li>run\u00a0<span class=\"lang:default decode:true  crayon-inline\">c:\\mongodb\\bin\\mongod.exe<\/span><\/li>\n<\/ul>\n<p>When you have <span class=\"lang:default decode:true  crayon-inline\">mongod.exe<\/span>\u00a0\u00a0started in one command window (I use <a href=\"http:\/\/sourceforge.net\/projects\/console\/\">Console2<\/a>) and you run <span class=\"lang:default decode:true  crayon-inline\">grunt <\/span>\u00a0in other you will get this in the &#8220;mongo&#8221; console:<\/p>\n<pre class=\"lang:default decode:true\">C:\\mongodb\\bin&gt;mongod.exe\r\nmongod.exe --help for help and startup options\r\nTue Mar 11 14:50:24.240 [initandlisten] MongoDB starting : pid=10136 port=27017 dbpath=\\data\\db\\ 64-bit host=Nikola-PC\r\nTue Mar 11 14:50:24.240 [initandlisten] db version v2.4.9\r\nTue Mar 11 14:50:24.240 [initandlisten] git version: 52fe0d21959e32a5bdbecdc62057db386e4e029c\r\nTue 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\r\nTue Mar 11 14:50:24.240 [initandlisten] allocator: system\r\nTue Mar 11 14:50:24.240 [initandlisten] options: {}\r\nTue Mar 11 14:50:24.244 [initandlisten] journal dir=\\data\\db\\journal\r\nTue Mar 11 14:50:24.244 [initandlisten] recover : no journal files present, no recovery needed\r\nTue Mar 11 14:50:24.323 [initandlisten] waiting for connections on port 27017\r\nTue Mar 11 14:50:24.324 [websvr] admin web console waiting for connections on port 28017\r\nTue Mar 11 14:50:40.982 [initandlisten] connection accepted from 127.0.0.1:58323 #1 (1 connection now open)\r\nTue Mar 11 14:50:41.014 [initandlisten] connection accepted from 127.0.0.1:58324 #2 (2 connections now open)\r\nTue Mar 11 14:50:41.024 [initandlisten] connection accepted from 127.0.0.1:58325 #3 (3 connections now open)\r\nTue Mar 11 14:50:41.024 [initandlisten] connection accepted from 127.0.0.1:58326 #4 (4 connections now open)\r\nTue Mar 11 14:50:41.025 [initandlisten] connection accepted from 127.0.0.1:58327 #5 (5 connections now open)<\/pre>\n<p>and this in the &#8220;grunt&#8221; console:<\/p>\n<pre class=\"lang:default decode:true\">C:\\Users\\Nikola\\Desktop\\mean&gt;grunt\r\nRunning \"jshint:all\" (jshint) task\r\n&gt;&gt; 42 files lint free.\r\n\r\nRunning \"concurrent:tasks\" (concurrent) task\r\nRunning \"nodemon:dev\" (nodemon) task\r\nRunning \"watch\" task\r\nWaiting...[nodemon] v1.0.15\r\n[nodemon] to restart at any time, enter `rs`\r\n[nodemon] watching: *.*\r\n[nodemon] starting `node --debug server.js`\r\ndebugger listening on port 5858\r\nExpress app started on port 3000<\/pre>\n<p>You can now take a look at your application by visiting localhost:3000 in your browser: <a href=\"http:\/\/nikola-breznjak.com\/blog\/wp-content\/uploads\/2014\/03\/meanHomeView.jpg\" rel=\"lightbox[308]\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-312\" src=\"http:\/\/nikola-breznjak.com\/blog\/wp-content\/uploads\/2014\/03\/meanHomeView.jpg\" alt=\"meanHomeView\" width=\"784\" height=\"218\" srcset=\"https:\/\/nikola-breznjak.com\/blog\/wp-content\/uploads\/2014\/03\/meanHomeView.jpg 784w, https:\/\/nikola-breznjak.com\/blog\/wp-content\/uploads\/2014\/03\/meanHomeView-300x83.jpg 300w\" sizes=\"auto, (max-width: 784px) 100vw, 784px\" \/><\/a> the signup screen: <a href=\"http:\/\/nikola-breznjak.com\/blog\/wp-content\/uploads\/2014\/03\/meanSignup.jpg\" rel=\"lightbox[308]\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-313\" src=\"http:\/\/nikola-breznjak.com\/blog\/wp-content\/uploads\/2014\/03\/meanSignup.jpg\" alt=\"meanSignup\" width=\"784\" height=\"612\" srcset=\"https:\/\/nikola-breznjak.com\/blog\/wp-content\/uploads\/2014\/03\/meanSignup.jpg 784w, https:\/\/nikola-breznjak.com\/blog\/wp-content\/uploads\/2014\/03\/meanSignup-300x234.jpg 300w\" sizes=\"auto, (max-width: 784px) 100vw, 784px\" \/><\/a> and signin screen: <a href=\"http:\/\/nikola-breznjak.com\/blog\/wp-content\/uploads\/2014\/03\/meanSignin.jpg\" rel=\"lightbox[308]\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-314\" src=\"http:\/\/nikola-breznjak.com\/blog\/wp-content\/uploads\/2014\/03\/meanSignin.jpg\" alt=\"meanSignin\" width=\"783\" height=\"462\" srcset=\"https:\/\/nikola-breznjak.com\/blog\/wp-content\/uploads\/2014\/03\/meanSignin.jpg 783w, https:\/\/nikola-breznjak.com\/blog\/wp-content\/uploads\/2014\/03\/meanSignin-300x177.jpg 300w\" sizes=\"auto, (max-width: 783px) 100vw, 783px\" \/><\/a><\/p>\n<h3>Ship it<\/h3>\n<p>In order to deploy to Nodejitsu, you have to login to Nodejitsu (<span class=\"lang:default decode:true  crayon-inline \">jitsu login<\/span>\u00a0) and then run\u00a0<span class=\"lang:default decode:true  crayon-inline \">jitsu deploy<\/span>\u00a0. At this point I got an error like this:<\/p>\n<pre class=\"lang:default decode:true\">info:    Starting app mean\r\nerror:   Error running command deploy\r\nerror:   Errors occured while starting the application\r\nerror:   Error output from application. This is usually a user error.\r\nerror:   grunt-cli: The grunt command line interface. (v0.1.13)\r\nerror:\r\nerror:   Fatal error: Unable to find local grunt.\r\nerror:\r\nerror:   If you're seeing this message, either a Gruntfile wasn't found or grunt\r\nerror:   hasn't been installed locally to your project. For more information about\r\nerror:   installing and configuring grunt, please see the Getting Started guide:\r\nerror:\r\nerror:   http:\/\/gruntjs.com\/getting-started\r\nerror:\r\nerror:   Error starting application. This could be a user error.\r\nerror:   info: Running start for app.\r\nerror:   info: Cleaning \/opt\/run\r\nerror:   info: Fetching application snapshot...\r\nerror:   info: Application snapshot fetched.\r\nerror:   info: Unpacking snapshot...\r\nerror:   info: Reading `package.json`...\r\nerror:   info: Starting application...\r\nerror:   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\r\nerror:   info: `aeternum` pid: 63258\r\nerror:   info: Writing pidfile: \/root\/app.pid\r\nerror:   info: Tailing forza log: \/opt\/run\/start.log\r\nerror:   info: Tail closing..\r\nerror:   info: Retry # 1 with 1000ms interval\r\nerror:   info: Tailing forza log: \/opt\/run\/start.log\r\nerror:   info: Tail closing..\r\nerror:   info: Success:start<\/pre>\n<p>and naturally, I went looking if someone had a similar issue and it turns out someone on Stackoverflow <a href=\"http:\/\/stackoverflow.com\/questions\/21846769\/launching-boilerplate-mean-io-app-to-nodejitsu-error\">asked this question<\/a>. The OP (<a href=\"http:\/\/meta.stackoverflow.com\/questions\/146513\/what-does-op-mean\">original poster<\/a>) did find a solution him self and he said:<\/p>\n<blockquote><p>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 &#8220;node server&#8221;.<\/p><\/blockquote>\n<p>Now, I tried to <a href=\"http:\/\/stackoverflow.com\/questions\/21846769\/launching-boilerplate-mean-io-app-to-nodejitsu-error#comment33941698_21900765\">communicate with the OP<\/a> to get some more info, but strangely no reply (yet). I figured it out myself in the end and this is how my <span class=\"lang:default decode:true  crayon-inline \">package.json<\/span>\u00a0\u00a0file looks like now:<\/p>\n<pre class=\"lang:default decode:true\">{\r\n  \"name\": \"mean\",\r\n  \"description\": \"MEAN - A fullStack javascript framework powered by  MongoDB, ExpressJS, AngularJS, NodeJS.\",\r\n  \"version\": \"0.1.2-1\",\r\n  \"private\": false,\r\n  \"repository\": {\r\n    \"type\": \"git\",\r\n    \"url\": \"https:\/\/github.com\/linnovate\/mean.git\"\r\n  },\r\n  \"engines\": {\r\n    \"node\": \"0.10.x\",\r\n    \"npm\": \"1.3.x\"\r\n  },\r\n  \"scripts\": {\r\n    \"start\": \"node server.js\",\r\n    \"test\": \"node node_modules\/grunt-cli\/bin\/grunt test\",\r\n    \"postinstall\": \"node node_modules\/bower\/bin\/bower install\"\r\n  },\r\n  \"dependencies\": {\r\n    \"express\": \"~3.4.7\",\r\n    \"bower\": \"~1.2.8\",\r\n    \"grunt-cli\": \"~0.1.11\",\r\n    \"connect-mongo\": \"~0.4.0\",\r\n    \"connect-flash\": \"~0.1.1\",\r\n    \"consolidate\": \"~0.10.0\",\r\n    \"swig\": \"~1.3.2\",\r\n    \"mongoose\": \"~3.8.3\",\r\n    \"passport\": \"~0.1.18\",\r\n    \"passport-local\": \"~0.1.6\",\r\n    \"passport-facebook\": \"~1.0.2\",\r\n    \"passport-twitter\": \"~1.0.2\",\r\n    \"passport-github\": \"~0.1.5\",\r\n    \"passport-google-oauth\": \"~0.1.5\",\r\n    \"passport-linkedin\": \"~0.1.3\",\r\n    \"lodash\": \"~2.4.1\",\r\n    \"forever\": \"~0.10.11\",\r\n    \"view-helpers\": \"~0.1.4\",\r\n    \"mean-logger\": \"0.0.1\"\r\n  },\r\n  \"devDependencies\": {\r\n    \"grunt-env\": \"~0.4.1\",\r\n    \"grunt-cli\": \"~0.1.11\",\r\n    \"grunt-contrib-watch\": \"latest\",\r\n    \"grunt-contrib-jshint\": \"latest\",\r\n    \"grunt-karma\": \"~0.6.2\",\r\n    \"grunt-nodemon\": \"0.2.0\",\r\n    \"grunt-concurrent\": \"latest\",\r\n    \"grunt-mocha-test\": \"latest\",\r\n    \"karma\": \"~0.10.4\",\r\n    \"karma-coffee-preprocessor\": \"~0.1.0\",\r\n    \"karma-coverage\": \"~0.1.0\",\r\n    \"karma-script-launcher\": \"~0.1.0\",\r\n    \"karma-chrome-launcher\": \"~0.1.0\",\r\n    \"karma-firefox-launcher\": \"~0.1.0\",\r\n    \"karma-html2js-preprocessor\": \"~0.1.0\",\r\n    \"karma-jasmine\": \"~0.1.3\",\r\n    \"karma-requirejs\": \"~0.2.0\",\r\n    \"karma-phantomjs-launcher\": \"~0.1.0\",\r\n    \"forever\": \"~0.10.11\",\r\n    \"supertest\": \"0.8.2\",\r\n    \"should\": \"2.1.1\"\r\n  },\r\n  \"subdomain\": \"hitman666-mean2\"\r\n}<\/pre>\n<p>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<\/p>\n<pre class=\"lang:default decode:true\">502 Reached max retries limit<\/pre>\n<p>I realized that I don&#8217;t have a correct MongoDB connection string, and in order to change this I had to edit the file <span class=\"lang:default decode:true  crayon-inline \">production.js<\/span>\u00a0which is in the <span class=\"lang:default decode:true  crayon-inline \">config\/env\/<\/span>\u00a0\u00a0folder.<a href=\"http:\/\/nikola-breznjak.com\/blog\/wp-content\/uploads\/2014\/03\/MongoDBconnectionString.jpg\" rel=\"lightbox[308]\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-large wp-image-391\" src=\"http:\/\/nikola-breznjak.com\/blog\/wp-content\/uploads\/2014\/03\/MongoDBconnectionString-1024x182.jpg\" alt=\"MongoDBconnectionString\" width=\"604\" height=\"107\" srcset=\"https:\/\/nikola-breznjak.com\/blog\/wp-content\/uploads\/2014\/03\/MongoDBconnectionString-1024x182.jpg 1024w, https:\/\/nikola-breznjak.com\/blog\/wp-content\/uploads\/2014\/03\/MongoDBconnectionString-300x53.jpg 300w, https:\/\/nikola-breznjak.com\/blog\/wp-content\/uploads\/2014\/03\/MongoDBconnectionString.jpg 1513w\" sizes=\"auto, (max-width: 604px) 100vw, 604px\" \/><\/a><\/p>\n<p>I copied the MongoDB connection string from Nodejitsu&#8217;s admin dashboard (I wrote about how to set this in my previous post: <a href=\"http:\/\/nikola-breznjak.com\/blog\/nodejs\/getting-started-with-nodejitsu-on-windows-by-deploying-a-men-framework\/\">Getting started with Nodejitsu on Windows by deploying a MEN framework<\/a>).<\/p>\n<p>After this change I deployed my app again, and now everything was working, yay!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Disclaimer: I&#8217;m in no way affiliated with Nodejitsu or MEAN.io. I&#8217;m just documenting my experience with them &#8211; problems (and solutions) I&#8217;ve faced while trying these new technologies&hellip;<\/p>\n","protected":false},"author":1,"featured_media":309,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[8,4],"tags":[17,23],"class_list":["post-308","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-codeproject","category-nodejs","tag-nodejitsu","tag-windows-2"],"_links":{"self":[{"href":"https:\/\/nikola-breznjak.com\/blog\/wp-json\/wp\/v2\/posts\/308","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/nikola-breznjak.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/nikola-breznjak.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/nikola-breznjak.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/nikola-breznjak.com\/blog\/wp-json\/wp\/v2\/comments?post=308"}],"version-history":[{"count":8,"href":"https:\/\/nikola-breznjak.com\/blog\/wp-json\/wp\/v2\/posts\/308\/revisions"}],"predecessor-version":[{"id":2034,"href":"https:\/\/nikola-breznjak.com\/blog\/wp-json\/wp\/v2\/posts\/308\/revisions\/2034"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/nikola-breznjak.com\/blog\/wp-json\/wp\/v2\/media\/309"}],"wp:attachment":[{"href":"https:\/\/nikola-breznjak.com\/blog\/wp-json\/wp\/v2\/media?parent=308"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/nikola-breznjak.com\/blog\/wp-json\/wp\/v2\/categories?post=308"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/nikola-breznjak.com\/blog\/wp-json\/wp\/v2\/tags?post=308"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}