AdonisJS is a Node.js framework, and hence it requires Node.js to be installed on your computer. To be precise, we need at least the latest release of
Node.js 14, along with
npm >= 6.0.0.
You can check the Node.js and npm versions by running the following commands.
# check node.js versionnode -v# check npm versionnpm -v
If you don't have Node.js installed, you can download the binary for your operating system from the official website.
npm init adonis-ts-app@latest hello-world# If using yarnyarn create adonis-ts-app hello-world
The installation process prompts for the following selections.
You can choose between one of the following project structures.
webproject structure is ideal for creating classic server-rendered applications. We configure the support for sessions and also install the AdonisJS template engine.
apiproject structure is ideal for creating an API server.
slimproject structure creates the smallest possible AdonisJS application and does not install any additional packages, except the framework core.
The name of the project. We define the value of this prompt inside the
Optionally, you can configure eslint and prettier. Both the packages are configured with the opinionated settings used by the AdonisJS core team.
Optionally, you can also configure webpack encore to bundle and serve frontend dependencies.
Please do note, AdonisJS is a backend framework and does not concern itself with front-end build tools. Hence the webpack setup is optional.
After creating the application, you can start the development server by running the following command.
node ace serve --watch
--watchflag is meant to watch the file system for changes and restart the server automatically.
By default, the server starts on
PORT 3333 (defined inside the .env file). You can view the welcome page by visiting http://localhost:3333
node ace build --production
The compiled output is written to the
build folder. You can
cd into this folder and start the server by directly running the
server.js file. Learn more about the typescript build process
cd buildnode server.js