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:
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:
No comments :
Post a Comment
What are your thoughts on this post? Did you like it?