http://expressjs.com/guide.html
겁먹지 말길! 그냥 영어 못해도.. 명령어만 그대로 따라 치면됨~ ㅋㅋ
음... '$' 다음이 명령어임;;
How to install Bootstrap (v2.0.2) in ExpressJS (v3.0.0)
http://www.rs.au.com/31/how-to-install-bootstrap-v2-0-2-in-expressjs-v3-0-0
I’m certainly no expert when it comes with using ExpressJS orBootstrap so there may be far better ways of doing this than what I detail below, however, if you do know of better ways please let me know as I bumbled my way through!
Here goes.
Prerequisites:
I’m installing this on an Ubuntu 11.10 EC2 micro instance and assuming that you have the following installed: node npm make zip unzip git
Process:
- Install via NPM the following: ExpressJS, Less & UglifyJS:
~$ npm install -g express less uglify-js
(you may need tosudo npm install -g express less uglify-js
- Create an ExpressJS working directory, we’ll call it testme, with Less:
~$ express --css less testme
- Move inside your new directory:
~$ cd testme
- Create a new directory called vendors:
~/testme$ mkdir vendors
- Move inside the vendors directory:
~/testme$ cd vendors
- Download from github Bootstrap:
~/testme/vendors$ git clone https://github.com/twitter/bootstrap.git bootstrap
- Move into the newly created Bootstrap directory:
~/testme/vendors$ cd bootstrap
- Build Bootstrap:
~/testme/vendors/bootstrap$ make -i
(you may see acannot remove `docs/assets/bootstrap.zip`
file –just ignore) – it would also be great if you couldmake
to a target directory, but I couldn’t find how this could be done. - Once the build has been completed move to the docs/assets directory:
~/testme/vendors$ cd bootstrap/docs/assets
- You should see a
css, img, js
folders and abootstrap.zip
file:~/testme/vendors/bootstrap/docs/assets$ ls
- Go back to the
testme
folder:~/testme/vendors/bootstrap/docs/assets$ cd ~/testme
- Move the bootstrap zip file you just created into your public folder:
~/testme$ mv vendors/bootstrap/docs/assets/bootstrap.zip public
- Move to the public folder:
~/testme$ cd public
- Unzip the bootstrap.zip file:
~/testme/public$ unzip bootstrap.zip
- You should see a bootstrap folder in the public folder
~/testme/public$ ls
- Remove the bootstrap.zip file:
rm bootstrap.zip
- Now it’s a matter of linking to the bootstrap stylesheets in your jade layout template files. Edit the
views/layout.jade
file to include references to the bootstrap files, remember Bootstrap needs the latest jQuery, so you may want to include reference to this too, here’s what mylayout.jade
looks like:
1234567891011 !!!htmlheadtitle= titlelink(rel='stylesheet', href='/bootstrap/css/bootstrap.min.css')link(rel='stylesheet', href='/bootstrap/css/bootstrap-responsive.min.css')link(rel='stylesheet', href='/stylesheets/style.css')script(src='http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js')script(src='/bootstrap/js/bootstrap.min.js')bodyblock content - To test that it works, edit the
views/index.jade
file to include a reference that Bootstrap will be able to use, something like:
123456789101112131415161718192021222324252627 extends layoutblock contentdiv.topform.form-horizontal(method="post", id="loginForm")label Usernameinput.span3(id="username", type="text", name="User", placeholder="Enter your username")label Passwordinput.span3(id="password", type="password", name="Password")input.btn(type="submit", value="Log In")div.containerdiv.contenttable.table.table-stripedtheadtrth Tableth Headingtbodytrtd Blahtd Testtrtd Hellotd Worlddiv.footerp © 2012 All rights reserved.
And there you have it! Being able to use a compiled Bootstrap file with your ExpressJS install.
'서버 > NodeJS' 카테고리의 다른 글
[NODEJS] chatting server git source (0) | 2013.10.23 |
---|---|
[NodeJS] Express를 MVC로 활용 (0) | 2013.08.27 |
[NodeJS] http proxy 랑 router 살짝 섞으니 좋군 (0) | 2013.08.27 |
[NodeJS] 패키지로 설치하기 (0) | 2013.08.25 |
[NodeJS] node.js 앱의 인스턴스를 관리해 주는 forever (0) | 2013.08.21 |