Unread Notifications

Latest Notifications

No Notifications

You're all set! Start a discussion by leaving a comment on a lesson or replying to an existing comment.

This series is outdated

Let's Learn AdonisJS 5 Preview

Let's Learn Adonis 5: Prerequisites & Creating A New Project

02:48 Watch
2:47 Read

We'll be learning a little about what Adonis is, the prerequisites to get started, and how to create a new project.

Watch on YouTube

Today we'll be starting our first Let's Learn. In these series we'll do deep-dives into particular topics, covering all the core concepts involved. In this Let's Learn, we'll be covering Adonis 5. Adonis 5 is a type-safe and extensive NodeJS framework.

Out of the box, Adonis includes routing, form validation, the Edge template engine, JSON serializers for your APIs, it's active-record ORM called Lucid, migrations, seeds, factories, multi-driver authentication, security, and more.

Adonis 5 Is Still In Preview

Adonis 5 is still in preview, however, as things progress toward the final release of Adonis 5 I will update this series accordingly. If you'd like to learn more on your own about Adonis 5, you can find more information on their site at: https://preview.adonisjs.com/.


There are a couple prerequisites you'll need to meed in order to progress with Adonis 5 and this series. You'll need NodeJS version 12.0.0 or later and NPM version 6.0.0 or later. You can check your versions in your terminal by running:

$ node -v
# v14.15.1

$ npm -v
# v6.14.8

Upgrading Using NVM

If you're using Node Version Manager (NVM) like I am, you can upgrade your node version to the latest release by running:

$ nvm install node
# Now using node v15.3.0 (npm v7.0.14)

This will install the latest release for both NodeJS and NPM.

To set this version of NodeJS and NPM as your default versions you can run the below.

$ nvm alias default 15.3.0
# replacing 15.3.0 with whatever version of node was installed for you

Upgrading Using Installer

If you're not using NVM, you can upgrade both NodeJS and NPM by downloading and running the latest Node installer from https://www.nodejs.org.

Just download the latest LTS or Current version, run the installer, and progress through the steps.

Creating Our Project

Now that we meet the requirements for Adonis 5, we're ready to create our application! To do this we can run the following in our terminal. Note that adonis5 below is where the project name goes, feel free to name your project whatever.

$ npm init adonis-ts-app adonis5

For the purposes of this series, when we're referencing our project path you'll see adonis5.

Next we'll be asked a couple of questions.

  1. Select the project structure: Web Application

    Web Applications will include the Edge template engine, the sessions module, static asset support, and CSRF protection.

    API Servers will be more suited for an API application including things like CORS and JSON content negotiation.

    For this series, we'll be building a Web Application, so be sure to select Web Application.

  2. Enter the project name: adonis5

    Feel free to enter whatever here.

  3. Setup eslint? false

    Again, your call here too. eslint will enforce codebase standards if you decide to set it up.

Congratulations! Your first Adonis 5 application has now been created. Now we can go ahead and change into our new project's directory.

$ cd adonis5

Then we can start the local server by running:

$ node ace serve --watch

Note that by adding --watch we're telling our server to watch for changes. You can alternatively run this command using NPM by running:

$ npm run dev

Now that our server is running we can open up our new project at the specified server port, the default port is 3333.

Once you open your application in the browser you should see a "It Works!" welcome page.

Next Up

In the next lesson, we'll discuss the project's structure and the basics of routing within our Adonis 5 application.


Prepared By

Tom Gobich

Burlington, KY

Owner of Adocasts, JavaScript developer, educator, PlayStation gamer, burrito eater.

Visit Website