Installation

This guide gets you started with AdonisJs by installing the framework and required dependencies. By the end of this guide, you will have a working AdonisJs web server with the Hello world page.

If you face any troubles installing AdonisJs, please file an issue on github.

Requirements

Since AdonisJs is a Node.js framework, please make sure Node.js is installed on your operating system with npm. Below are the minimum required versions.

  1. Node.js 8.0 or greater.

  2. Npm 3.0 or greater.

You can also make use of nvm to manage and run multiple versions of Node.js

Cli tool

Once requirements to run AdonisJs Apps are met, the next step is to install the cli tool, which will help us in creating new AdonisJs applications.

The cli tool is installed globally using npm.

npm i -g @adonisjs/cli

Once the installation completes, make sure that you can run adonis from your command line.

adonis --help

Continue, if everything works as expected. Otherwise please create an issue on github

Creating new app

Let’s start by creating a new application using the cli tool new command. It accepts the project name/folder as a required parameter.

adonis new yardstick
Output
    _       _             _         _
   / \   __| | ___  _ __ (_)___    | |___
  / _ \ / _` |/ _ \| '_ \| / __|_  | / __|
 / ___ \ (_| | (_) | | | | \__ \ |_| \__ \
/_/   \_\__,_|\___/|_| |_|_|___/\___/|___/

✔ Your current Node.js & npm version match the AdonisJs requirements!
✔ Cloned [adonisjs/adonis-fullstack-app]
✔ npm: Dependencies installed
✔ Default environment variables copied
✔ generated unique APP_KEY
┌───────────────────────────────────┐
│        Application crafted        │
│                                   │
│        cd yardstick               │
│        adonis serve --dev         │
└───────────────────────────────────┘

Running application

Once the installation process is completed, you can cd into the directory and run the following command to start the HTTP server.

adonis serve --dev
Output
Started server in dev mode

[date] - info: serving app on 127.0.0.1:3333

The serve command starts the HTTP server on port defined inside the .env file in the project root. If you open 127.0.0.1:3333 inside your browser, you will see the following welcome page.

welcome page

Customizing new command

  1. The adonis new <PATH> command creates the project directory and does npm install for you automatically. You can pass --yarn to make use of yarn over npm.

  2. By default fullstack app blueprint is cloned from Github, which can be customized by passing --slim or --api-only flag.

  3. To make use of community created blueprints, you can pass --blueprint=<github-org/repo>.

When in doubt, make use of the adonis new --help command to see the list of available options.

Next Steps

This guide was small and focused only on the installation part of the process. Going forward we will learn about the HTTP lifecycle and the folder structure.