Chapter 1Getting Ready

1Installing Node.js   

http://nodejs.org,

after installed ,open cmd,To test the Node.js installation, open a command line and type node. Wait until the prompt changes and then
enter the following (on a single line):
function testNode() {return "Node is working"}; testNode();

When used interactively, Node.js will evaluate input as JavaScript, and you will see the following output if the
installation has been successful:
'Node is working'


2 Installing the Web Server(if nodejs folder is at C:\Program Files)參考2014-09-30_173136.jpg

cmd   command

cd \

cd  Program Files

cd nodejs

npm install connect


2.1 在nodejs文件夾裡面新建一個server.js,內容如下

var connect = require('connect');
connect.createServer(
connect.static("../angularjs")
).listen(5000);


Remark:书里写的如上,但是后面运行时候发生错误,

C:\Program Files\nodejs> node server.js

module.js:340
    throw err;
          ^
Error: Cannot find module 'serve-static'
    at Function.Module._resolveFilename (module.js:338:15)
    at Function.Module._load (module.js:280:25)
    at Module.require (module.js:364:17)
    at require (module.js:380:17)
    at Object.<anonymous> (C:\Program Files\nodejs\server.js:4:15)
    at Module._compile (module.js:456:26)
    at Object.Module._extensions..js (module.js:474:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:312:12)
    at Function.Module.runMain (module.js:497:10)
查阅之后,找到原因如下

Solved:  The connect package has made some changes in the latest 3.x version of their code base, moving the  static  middleware to it's own package.  You can view the list of packages that have been moved here .
So you have two options:

Option 1
You can install an older, 2.x version of connect and use that as is:

$ npm install connect@2.X.X

Installing the latest 2.X.X version will allow your current implementation to function properly.

Option 2
You can continue to use the 3.x version of connect, and also add serve-static:

$ npm install serve-static

You would also have to update your server.js file to include the new serve-static module:

var connect = require('connect'),
    serveStatic = require('serve-static');

var app = connect();

app.use(serveStatic("../angularjs"));
app.listen(5000);
最终解决步骤:1 cmd cd 到 nodejs 文件夹,然后 npm install serve-static     

 2  修改文件server.js

ar connect = require('connect'),
    serveStatic = require('serve-static');

var app = connect();

app.use(serveStatic("../angularjs"));
app.listen(5000);

2.2 nodejs folder所在的位置,创建一个folder,名字为angularjs


Installing the Test System
cmd cd 到 nodejs folder所在的位置
npm install -g karma

 


2.3 照书上说的安装angular和bootstrap

http://angularjs.org

http://getbootstrap.com


2.4下载source code(里面包含了需要用的Deployd和每一章的code)

www.apress.com

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值