AdonisJS is a Node.js framework and hence it requires Node.js to be installed on your computer. To be precise, we require
Node.js >= 14.15.4, 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, then you can download the binary for your operating system from the official website.
npm init [email protected] 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.
Do note, AdonisJS is a backend framework and does not concern itself with frontend 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.
node ace build --production
The compiled output is written to the
build folder. You can
cd into this folder and start the server by running the
serve.js file directly. Learn more about the typescript build process
cd buildnode server.js