npm start
コマンドを実行すると、 package.json の script.start コマンドが実行される
"scripts": {
"start": "NODE_ENV=production NODE_PATH=lib node --harmony_typeof --harmony"
}
http://d.hatena.ne.jp/Jxck/20120410/1334071898 Node.js の起動オプション、環境変数、npm start の話
<html> | |
<head> | |
<style type="text/css"> | |
div { | |
width: 600px; | |
height: 50px; | |
} | |
.blue { background-color: blue; } | |
.green { background-color: green; } |
var fs = require('fs'), | |
path = require('path'); | |
(function scan(dir) { | |
fs.readdirSync(dir).forEach(function (item) { | |
var stat = fs.statSync(path.join(dir, item)); | |
if (stat.isFile()) require(path.join(dir, item)); | |
else if (stat.isDirectory()) scan(path.join(dir, item)); | |
}); | |
})('./lib/some/dir'); |
var http = require('http') | |
, connect = require('connect') | |
, app | |
; | |
app = connect() | |
.use(assetsExpire(1000 * 60 * 3)) | |
.use(connect.static('public')) | |
.use(function(req, res){ | |
res.end(' \ |
var http = require("http") | |
, server | |
; | |
server = http.createServer(function (req, res) { | |
res.writeHead(200); | |
res.end("<html><body><p>hi i am hidakaya</p></body></html>"); | |
}); | |
module.exports = server; |
var path = require('path') | |
, mode = process.env.NODE_ENV || 'development' | |
, env = require(path.resolve('resources/environments', mode)) | |
; | |
console.log(env.WHOAMI); | |
// output: dev太郎 |
npm start
コマンドを実行すると、 package.json の script.start コマンドが実行される
"scripts": {
"start": "NODE_ENV=production NODE_PATH=lib node --harmony_typeof --harmony"
}
http://d.hatena.ne.jp/Jxck/20120410/1334071898 Node.js の起動オプション、環境変数、npm start の話
function Window() { | |
.... | |
} | |
Window.prototype.build = function () { | |
this.setWidet(); | |
} | |
Wondow.prototype.setWidget = function () { | |
this.root.add(this.widget.tabMenue); |
The question: how can we use ES6 modules in Node.js, where modules-as-functions is very common? That is, given a future in which V8 supports ES6 modules:
export
syntax, without breaking consumers that do require("function-module")()
?import
syntax, while not demanding that the module author rewrites his code to ES6 export
?@wycats showed me a solution. It involves hooking into the loader API to do some rewriting, and using a distinguished name for the single export.
This is me eating crow for lots of false statements I've made all over Twitter today. Here it goes.
(function () { | |
var queue; | |
queue = createQueue(0, 0, 100, 100, 25, function (xMin, yMin, xMax, yMax) { | |
var x, y; | |
for (x = xMin; x < xMax; x++) { | |
for (y = yMin; y < yMax; y++) { | |
// do someThing | |
} | |
} | |
}); |