1Installing Node.js
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:书里写的如上,但是后面运行时候发生错误,
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)
static
middleware to it's own package.
You can view the list of packages that have been moved here
.
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);
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
2.3 照书上说的安装angular和bootstrap
http://angularjs.org
http://getbootstrap.com
2.4下载source code(里面包含了需要用的Deployd和每一章的code)
www.apress.com