Language ignition
JavaScript (node.js)
- Installation
- Start a new project
- Initialise your project
- Install a library
- Install a command-line tool
Example text has a yellow background. You should replace the example text with the appropriate text for your situation.
Suggested text has a blue background. The suggested text should work fine, but you can replace it with an alternative of your choosing if you like.
Installation
Download and untar the appropriate tarball from nodejs.org,
and add symlinks for the programs to a directory on your PATH.
Assuming you're on x86-64 Linux and ~/bin
is on your path:
$ mkdir -p ~/apps/node
$ cd ~/apps/node
$ wget http://nodejs.org/dist/v0.10.16/node-v0.10.16-linux-x64.tar.gz
$ tar xzf node-v0.10.16-linux-x64.tar.gz
$ ln -s node-v0.10.16-linux-x64 current
$ ln -s ~/apps/node/current/bin/node ~/bin
$ ln -s ~/apps/node/current/bin/npm ~/bin
Start a new project
Create a file called README.md
that describes your project to a human using Markdown.
Create a file called package.json
that contains meta-data for your project.
{
"name": "language-ignition",
"version": "0.1.0",
"author": "Michael Williamson <mike@zwobble.org>",
"description": "Get started with a new language",
"keywords": ["language"],
"main": "./lib/index.js",
"repository": {
"type": "git",
"url": "https://github.com/mwilliamson/patter.git"
},
"dependencies": {
"promise": "~2.0.0"
},
"devDependencies": {
"nodeunit": "~0.8.0"
},
"license": "BSD",
"scripts": {
"test": "nodeunit tests"
}
}
Initialise your project
Make sure you're at the root of your project, which should contain package.json
$ npm install
Install a library
Let's assume we want to install promise.
$ npm install promise
Install a command-line tool
Let's assume we want to install browserify.
Create a directory to install the tool, including a node_modules
sub-directory:
$ mkdir -p ~/apps/browserify/node_modules
Install the tool:
$ cd ~/apps/browserify
$ npm install browserify
Run the tool:
$ ~/apps/browserify/node_modules/.bin/browserify
Optionally create a symlink in a directory that's on your $PATH
. Assuming ~/bin is on your path:
$ ln -s ~/apps/browserify/node_modules/.bin/browserify ~/bin