今さらながらNode.js入門その2
前回の続き。
注記
以下、個人のメモです。正しい記述を心がけますがいい加減な所もあると思うので悪しからず。間違いの指摘は歓迎です。
node コマンドいろいろ試してみる
help
$ node --help Usage: node [options] [ -e script | script.js ] [arguments] node debug script.js [arguments] Options: -v, --version print node's version -e, --eval script evaluate script -p, --print print result of --eval -i, --interactive always enter the REPL even if stdin does not appear to be a terminal --no-deprecation silence deprecation warnings --trace-deprecation show stack traces on deprecations --v8-options print v8 command line options --max-stack-size=val set max v8 stack size (bytes) Environment variables: NODE_PATH ':'-separated list of directories prefixed to the module search path. NODE_MODULE_CONTEXTS Set to 1 to load modules in their own global contexts. NODE_DISABLE_COLORS Set to 1 to disable colors in the REPL Documentation can be found at http://nodejs.org/
バージョン表示
$ node -v
v0.8.28
引数をスクリプトとして評価実行
$ node -e 'console.log("Hello, Node.js!");' Hello, Node.js!
-e
の評価結果を出力
$ node -p -e 'console.log(Math.PI);' 3.141592653589793 undefined
標準入力からのREPL実行のように実行
$ node -i < math.js > console.log(Math.PI); > 3.141592653589793 undefined >
v8 オプションいろいろ
$ node --v8-options Usage: shell [options] -e string execute string in V8 shell [options] file1 file2 ... filek run JavaScript scripts in file1, file2, ..., filek shell [options] shell [options] --shell [file1 file2 ... filek] run an interactive JavaScript shell d8 [options] file1 file2 ... filek d8 [options] d8 [options] --shell [file1 file2 ... filek] run the new debugging shell Options: --use_strict (enforce strict mode) type: bool default: false --es5_readonly (activate correct semantics for inheriting readonliness) type: bool default: false --es52_globals (activate new semantics for global var declarations) type: bool default: false --harmony_typeof (enable harmony semantics for typeof) type: bool default: false --harmony_scoping (enable harmony block scoping) type: bool default: false --harmony_modules (enable harmony modules (implies block scoping)) type: bool default: false --harmony_proxies (enable harmony proxies) type: bool default: false (以下省略)
いっぱいある。
続きは次回。