Getting Started

Welcome to Modulus! This guide will walk you through all the necessary steps to deploy a Node.js application on the Modulus platform.

Video

1. Write Something

Modulus Demo App

If you’d like to exercise the platform and don’t have an application ready yet, grab the Modulus demo application.

git clone git://github.com/onmodulus/modulus-demo.git

Your Own App

If you’ve got an application ready to deploy, there’s only a few requirements to ensure everything goes smoothly.

  1. Use the environment variable PORT.
    app.listen(process.env.PORT)
  2. Specify dependencies in package.json. Note only the dependencies will be installed. Any other dependencies section, such as devDependencies, will not be installed.
    {
      "name": "my-application",
      "version": "0.0.1",
      "description": "My application description.",
      "main": "app.js",
      "dependencies" : {
        "express" : "2.5.x",
        "ejs" : "0.8.x"
      }
    }
  3. Specify the main file in package.json. Modulus will automatically look for a file named app.js. If your main file is named something else, it must be specified.
    {
      "name": "my-application",
      "version": "0.0.1",
      "description": "My application description.",
      "main": "path/to/custom_main.js",
      "dependencies" : {
        "express" : "2.5.x",
        "ejs" : "0.8.x"
      }
    }
  4. Specify the version of Node, otherwise the latest stable release will be used. Modulus supports Node versions 0.2.0 and up.
    {
      "name": "my-application",
      "version": "0.0.1",
      "description": "My application description.",
      "main": "path/to/custom_main.js",
      "dependencies" : {
        "express" : "2.5.x",
        "ejs" : "0.8.x"
      },
      "engines" : {
        "node": "0.10.x"
      }
    }

2. Install Modulus CLI (optional)

In most cases, the the command line tool (CLI) is going to be a more convenient way to deploy an application. The CLI is optional and every task can also be performed using the web interface.

$ npm install -g modulus

3. Log In

If you are using the CLI you will need to log in before you can create or deploy a project. Assuming you have already created an account, logging in through the CLI is easy.

The Modulus CLI stores authentication information locally (stores a token, not actual username and password), so logins are only required once. Use the logout command to remove this information and force a re-login.

$ modulus login
Welcome to Modulus
[?] Enter your username or email: parker@example.com
[?] Enter your password:
[✓] Signed in as user spiderman

If you created an account using GitHub, you can use the --github (-g) option and log in with your GitHub credentials.

$ modulus login --github
Welcome to Modulus
[?] Enter your GitHub username or email: pparker
[?] Enter your password:
[✓] Signed in as user spiderman

4. Create Project

A project can be created through the user dashboard or the Modulus CLI.

Modulus CLI

Simply run the project create command.

$ modulus project create 
Welcome to Modulus 
You are logged in as spiderman 
[?] Enter a project name: Lizard Locator

Web Interface

On your user dashboard, click "Create New Project" and type in a name. Creating a new project.

5. Deploy

Deploy

$ cd path/to/project
$ modulus deploy
[?] Are you sure you want to use project Lizard Locator? (yes)
Compressing project...
6.6 MB written
Uploading project...
Upload progress [===================] 100%
Deploying Project...
Deploying [       =            ] 
[✓] Lizard Locator running at lizard-locator-895.onmodulus.net

Web Interface

Zip Project Directory Contents

You can use any zip tool of your choice. If you’re on Mac or Linux, here’s a convenient way to zip the contents using the command line.

$ cd path/to/project
$ zip -r myProject.zip .
(Don’t forget the dot at the end)

Upload Zip File

  1. Log in to Modulus and enter your Project Dashboard. Locate the Deploy block and click the “Browse Button”. The deploy section on the project dashboard.
  2. Select the zip file you just created and then click “Upload”. The deploy dialog.
  3. Wait for the deploy dialog to complete. When it’s done, your application is live.
comments powered byDisqus