react-social-login

The easiest way to integrate Social Login in your React Apps ...Checkout NPM

Saturday, July 19, 2014

Setting Deployd and Nodejs for Apress professional angularjs

If you're reading Professional Angular Apress book (One of the best books I've read), for practical exercises you'd need to make some installations. Unfortunately, the book text is a little outdated as far as installation is considered. I'm just summarizing steps (that worked for me on Windows box).

1. Install NodeJS
This is simple. Download and install NodeJS from http://nodejs.org/

If you just want to test if Node is properly installed:
a. open command prompt
b. type node and enter
c. Type  following and enter
    function testNode() {return "Node is working"}; testNode();

If "Node is working" dispays, its working fine.

2. Using Nodejs as web server
Here you would run a little out of luck by following steps as are defined in book.
2.1. Install Connect NodeJs plugin
This is same as in book.
a. Open command prompt and navigate to folder where NodeJs is installed (in my case C:\Program Files\nodejs)
b. type npm install connect and enter

2.2 Install ServeStatic NodeJs plugin
Within the same folder as above in a , type npm install serve-static and enter

2.3 Server.js file
Instead of text in book, use following:

var connect = require('connect'),
    serveStatic = require('serve-static');
var app = connect();
app.use(serveStatic("../angularjs"));
app.listen(5000);

Note: If you want to specify a specific path, ensure to escape slashes. for example:
app.use(serveStatic("D:/\MyBooks/\Frontend/\angular/\angularJs"));


2.4 Validating
a. open command prompt and run node server.js
b. open browser and type http://localhost:5000/test.html

The above code assumes that you've created a folder "angularjs" at the same level as Nodejs (not inside NodeJs folder). If you've created it inside you'd need to remove ../ otherwise NodeJs will give error
Cannot Get /test.html. Also it assumes that there is a test.html file.

3. Installing Deployd
If you go to deployd.com and try to download installer (which is in Google Drive), you'd see following message:
Sorry, this file is infected with a virus
Only the owner is allowed to download infected files.

The file is actually not infected. To get deployd, you've 2 options:
a. Download the sourcecode of book from http://www.apress.com/9781430264484 which contains a copy of installer
b. Other way is to fool Google Drive by:
- From file menu, choose Move to Folder  and move it to your own G drive
- It will still show the owner as Jeffery Cross in your drive. Right Click the file name and select Make a copy  from context menu.
Now the file will be copied into your drive with your name in owner. You can download it then.

4. Creating Sportsstore
I'm not sure if MongoDb is a pre-requisite or deployd installer has all what's needed. But I was getting some error upon trying to run sportsstore for which :
a. I downloaded and installed MongoDb from www.mongodb.com
b. Give full access to yourself (everyone is even better) to the folder that will have sportsstore (if you're following book, thie would be the deployd folder created by yourself). I was getting
{error 'EACESS', syscall:listen} otherwise.

Finally, to launch create and launch your sportsstore
a. open command prompt and navigate to folder you created in 4.
b. run dpd create sportsstore
c. run cd sportsstore
d. run dpd

voila! Your page will open in browser.
You'are all set to try practical chapters.


No comments :

Post a Comment

What are your thoughts on this post? Did you like it?