Learn Sails.js - Part 1

von Manuel am 24.08.2025 um 12:00 Uhr

Let’s lay the keel for our first vessel.


Part 1: Commissioning Your First Sloop


The Captain’s Briefing (Background and Theory)

Welcome to the main shipyard, Seaman. Your theoretical training is over; it’s time to get your hands dirty. In this module, we will take the Sails.js blueprint you acquired and command the shipyard to construct our first ship. This process is called scaffolding.

The sails new Command: Laying the Keel

The sails new <your-app-name> command is your first order as a shipbuilder. When you issue this command, Sails acts as your master foreman. It doesn’t just create an empty folder; it scaffolds a complete project structure. It lays the keel, erects the frame, and builds out all the necessary decks and compartments according to the proven MVC blueprint. This saves you from the tedious and error-prone task of creating every file and folder by hand.

Anatomy of a Sloop: The Generated Folder Structure

Once the scaffolding is complete, you’ll have a new directory filled with files and other folders. At first, it might look intimidating, but it’s logically organized like a real ship. Let’s inspect the three most important areas for now:

The sails lift Command: Launching into the Water

A ship in dry-dock is just a sculpture. The sails lift command is the order to “open the floodgates and launch the vessel!” When you run this command from inside your project directory, Sails.js does several things:

  1. It reads all your configuration files.
  2. It loads all your models, controllers, and services.
  3. It starts a web server on your computer.
  4. It begins listening for incoming HTTP requests on a specific port (the default is 1337).

The famous Sails ASCII art of a ship that appears in your terminal is your confirmation: your ship is now afloat in your local development harbor (localhost).


Key Concepts Checklist


Mission Log: Quest - “Launch Ceremony”

It’s time to build. Follow these orders precisely to construct and launch the-sea-serpent.


Mission Debrief (Review & Outcomes)

Congratulations, Seaman! You have successfully commanded the construction and launch of your first vessel, the-sea-serpent. It is no longer just a collection of files; it is a living, breathing web server floating in your local harbor, ready to receive orders.

You have mastered the two most fundamental commands in the framework: sails new and sails lift. You have also taken your first tour of a Sails.js application’s structure, a layout that will soon become second nature to you.

The ship is afloat, but it currently has no rudder. It can only sit at the dock. In our next part, we will step onto the bridge and learn how to steer.


Rewards