Creating a Node.js project with grunt-init

November 22, 2014

Install Grunt's project scaffolding tool grunt-init:

$ npm install grunt-init

Install the Node.js grunt-init template:

$ git clone https://github.com/gruntjs/grunt-init-node.git ~/.grunt-init/node

Specify default prompt answers:

~/.grunt-init/defaults.json:

{
    "author_name": "James Earl Douglas"
  , "author_email": "james@earldouglas.com"
  , "author_url": "https://earldouglas.com/"
}

Create a new project directory:

$ mkdir hello
$ cd hello

Run the project creation wizard:

$ grunt-init node

Install the project's Node.js dependencies:

$ npm install

Run the project's tests with Grunt:

$ grunt nodeunit
Running "nodeunit:files" (nodeunit) task
Testing hello_test.js.OK
>> 1 assertions passed (9ms)

Done, without errors.

Run the project's tests with npm:

$ npm test

> hello@0.1.0 test /home/james/hello
> grunt nodeunit

Running "nodeunit:files" (nodeunit) task
Testing hello_test.js.OK
>> 1 assertions passed (8ms)

Done, without errors.