Negatory. Postpone Mission.
    Wondering what’s next for npm?Check out our public roadmap! »


    0.4.0 • Public • Published

    Node.js - rock

    Rock generates file structures or project skeletons based off of predefined templates.


    Do you constantly finding yourself writing a lot of new libraries for Node.js and having to create the package.json, README, LICENSE, lib/, test/ files over and over again? Well, I did. I was getting annoyed of having to create the same file structure over and over again.

    I stumbled upon a few solutions, but they all seem to do more than just generate a file structure from a template. That's all I wanted. Oh, and I wanted it to be programmatic too. So, if I wanted to build a blogging engine or another Rails clone in JS, I could leverage rock to generate the empty templates.

    As it stands now, rock is written in Node.js. But the actual templates themselves could be for any language.


    You will need Node.js and npm (Node.js Package Manager). This is bundled with Node.js. If you don't have npm, mozy on over to the Node.js download page. There are prebuilt binaries and installers for most platforms including Mac OS X, Windows, and Linux.

    After you have installed Node.js and npm, you can install rock by running the following command:

    npm install -g rock

    Don't forget the -g flag. This will ensure that the rock command is available system wide.


    rock [path] -r [rock]


    rock mylib -r node-lib


    rock /tmp/mylib -r node-lib


       --version              Print version and exit.
       -r ROCK, --rock ROCK   The rock path or Github repo.
       -c, --config           The config file. Defaults to ~/.rock/rock.conf.json
       -f, --file             If the rock is a single file. Supports http as well.  [false]
       --topen                Opening template value. Defaults to {{  [{{]
       --tclose               Closing template value. Defaults to }}  [}}]

    Want to create a project from a rock hosted somewhere else? No problem:

    rock myapp -r

    or use Github shorthand:

    rock myapp -r johndoe/myrepo

    Make Your Own Rocks

    It's stupidly simple to make your own rocks. Create a Git repository on Github or an empty directory on your filesystem. Start making template files.

    Example (myproject.js):

       Author: {{author}} <{{email}}>
       File: {{-file}}
       Created: {{-date}}
    function main() {

    Now, when you run:

    rock myproj -r /path/to/my/rock/repo

    Rock will prompt:


    Rock, then will create the file structure of your new project with the values of your template tokens replaced with what you typed. Rock already understands -file, -date, and a few others.

    Ignore Directories

    In your rock repo, add a file .rock/rock.json. Add the following:

        "ignoreDirs": ["./dirToIgnore"]

    Why would you do this? Let's say that you're calling rock programmatically and you don't want rock to prompt you for any tokens because you are going to use Mustache/Hogan/Handlebars in your own code.

    Open / Close Templates

    If you don't want to use the default {{ and }} and want to use something else, you can configure this behavior for your Rock in .rock/rock.json:

      "tokens": {
        "open": "#{",
        "close": "}"

    You may want to do this if you generate files that actually use Mustache templates.

    Single File Rocks

    Rock doesn't need to be used with just whole repos. It can be used with individual files as well.



    Hi, @@author@@ is going to build:


    rock /tmp/outputfile.txt -f --topen '@@' --tclose '@@' -r http://localhost/data.txt


    author: JP
    project-name: Rock



    Hi, JP is going to build:


    This file defaults to ~/.rock/rock.conf.json. You can set default values (prompt or skip).

      "templateValues": {
        "author": "JP Richardson"
      "defaultValues": {
        "email": ""

    So, if you were to run:

    rock myapp -r rocktemplates/node-bin

    it would not prompt you for author and it would prompt you for email but with a default of


    See more rocks at: or browse 3rd party Rocks here:

    Roadmap to v1.0.0

    • Will probably change configuration from JSON to TOML. TOML needs to achieve stability first.
    • Create/fork site similar to



    (The MIT License)

    Copyright (c) 2012-2013, JP Richardson


    npm i rock

    DownloadsWeekly Downloads






    Last publish


    • avatar
    • avatar