https://github.com/joyent/node/wiki/Installing-Node.js-via-package-manager
インストール手順:
sudo apt-get update sudo apt-get install python-software-properties python g++ make sudo add-apt-repository ppa:chris-lea/node.js sudo apt-get update sudo apt-get install nodejs Expressインストール(MVC) sudo npm install express -g express --version 3.4.0
インストール先:
/usr/lib/nodejs
/usr/lib/node_modules
Expressでサンプルサイトsite1を作る
$express site1 create : site1 create : site1/package.json create : site1/app.js create : site1/public create : site1/public/javascripts create : site1/public/stylesheets create : site1/public/stylesheets/style.css create : site1/routes create : site1/routes/index.js create : site1/routes/user.js create : site1/views create : site1/views/layout.jade create : site1/views/index.jade create : site1/public/images install dependencies: $ cd site1 && npm install run the app: $ node app $cd site1 $sudo npm install -d $node app.js Express server listening on port 3000
LESSインストール
$cd site1 $nano package.json ... { "name": "application-name", "version": "0.0.1", "private": true, "scripts": { "start": "node app.js" }, "dependencies": { "express": "3.4.0", "jade": "*", "less-middleware": "*" } } ... $nano app.js ... var express = require('express'); var routes = require('./routes'); var user = require('./routes/user'); var http = require('http'); var path = require('path'); var app = express(); // all environments app.set('port', process.env.PORT || 3000); app.set('views', __dirname + '/views'); app.set('view engine', 'jade'); app.use(express.favicon()); app.use(express.logger('dev')); app.use(express.bodyParser()); app.use(express.methodOverride()); app.use(app.router); app.use(require('less-middleware')({ src:__dirname + '/public', compress:true })); app.use(express.static(path.join(__dirname, 'public'))); // development only if ('development' == app.get('env')) { app.use(express.errorHandler()); } app.get('/', routes.index); app.get('/users', user.list); http.createServer(app).listen(app.get('port'), function(){ console.log('Express server listening on port ' + app.get('port')); }); ... $sudo npm install -d $nano public/stylesheets/style.less ... h1 {font-size:200px;} ... #public/stylesheets/style.cssは自動的に作成される
0 件のコメント:
コメントを投稿