User:Hashar/cli-js

''Note taking mostly. Do not quote me on this stuff!''

prerequisites
Install language interpreters python 2.7 and node.js. On a Mac OS X Computer, it will be with the port command (see MacPorts): $ sudo port install python2.7 $ sudo port install node # got me node 0.4.8

Then install "Node Package Manager" (npm) with a small risk of getting hacked in the way:

% Total   % Received % Xferd  Average Speed   Time    Time     Time  Current Dload Upload   Total   Spent    Left  Speed 100 3874  100  3874    0     0   8970      0 --:--:-- --:--:-- --:--:-- 13451 fetching: http://registry.npmjs.org/npm/-/npm-1.0.6.tgz /tmp/npm.50407/package 0.4.8 1.0.6 prefix=/opt/local
 * 1) curl http://npmjs.org/install.sh | sh

This script will find and eliminate any shims, symbolic links, and other cruft that was installed by npm 0.x.

Is this OK? enter 'yes' or 'no' yes <--- enter 'yes' and press return :)

All clean! ! [ -d .git ] || git submodule update --init node cli.js cache clean node cli.js rm npm -g -f --loglevel error node cli.js install -g -f /opt/local/bin/npm -> /opt/local/lib/node_modules/npm/bin/npm.js node-uuid@1.1.0 /opt/local/lib/node_modules/npm/node_modules/node-uuid npm@1.0.6 /opt/local/lib/node_modules/npm It worked

Then install node-qunit ( https://github.com/kof/node-qunit ) using the node package manager:

$ sudo npm install qunit

> qunit@0.1.5 install ~/node_modules/qunit > make install

... output of ./configure && make && make install

argsparser@0.0.5 ./node_modules/qunit/node_modules/argsparser uglify-js@1.0.2 ./node_modules/qunit/node_modules/sharedjs/node_modules/uglify-js sharedjs@0.0.2 ./node_modules/qunit/node_modules/sharedjs qunit@0.1.5 ./node_modules/qunit

setup profile and check installation
You should have something like:

$ sudo npm list /path/to/home └─┬ qunit@0.1.5 ├── argsparser@0.0.5 └─┬ sharedjs@0.0.2 └── uglify-js@1.0.2 $

NPM actually install the requested modules under /path/to/home/node_modules/ and then use a symbolic link to publish the binary. The folder can be found by using :

$ npm bin /path/to/home/node_modules/.bin $

You might want to append that binary path to your PATH environment variable: NODE_PATH="/Users/hashar/node_modules" export PATH=$PATH:"$NODE_PATH/.bin"
 * 1) node.js

At this step, you should be ready to run qunit :

$ which qunit /path/to/home/node_modules/.bin/qunit $ qunit -h

Usage: cli [options] value (boolean value can be used)

...

Please use the -h switch when invoking qunit or it might just throw an exception.

Jquery and DOM
Install Jquery and a javascript DOM for node is really easy, using the Node Package Manager of course!

jQuery for node: $ npm install jquery htmlparser@1.7.3 ./node_modules/jquery/node_modules/htmlparser mjsunit.runner@0.1.3 ./node_modules/jquery/node_modules/jsdom/node_modules/mjsunit.runner request@1.9.5 ./node_modules/jquery/node_modules/jsdom/node_modules/request jsdom@0.1.20 ./node_modules/jquery/node_modules/jsdom jquery@1.5.1 ./node_modules/jquery $

DOM in node: $ npm install jsdom request@1.9.5 ./node_modules/jsdom/node_modules/request htmlparser@1.7.3 ./node_modules/jsdom/node_modules/htmlparser jsdom@0.2.0 ./node_modules/jsdom $

First node run
Create a JavaScript file with the following content (From https://github.com/coolaj86/node-jquery) :

Then run the above code using node: $ node qunit_start.js test passes $

Congratulations! You have everything needed :-)