Getting Started With Sails.js: Install Node, Sails, and Postgres

In this article, I show you how to setup Sails.js.

Install NodeJS

Visit and download the LTS version of Node. At the time of writing this was v.4.4.5 LTS.

Follow the installer to completion.

Once completed open up Terminal and check your node version.

node -v

Install Postgres

Download onto your machine and follow the installation process.

Once installed, open the psql command.

Then, create the database.

CREATE DATABASE yourapp_development;

Install Sails.js

sudo npm -g install sails

Create a project.

sails new yourapp

Enter the project and install postgresql.

Configure Postgres with Sails

npm install sails-postgresql --save

Open config/connections.js and add the following to the end of the file.

postgresDevelopment: {
  adapter: 'sails-postgresql',
  url: 'postgres://postgres@localhost/yourapp_development',
  ssl: false

Good. Next open config/models.js, uncomment the connection: line, and set to postgresql.

connection: 'postgresDevelopment',

Start the app

Save those changes and start the app.

cd yourapp
npm start

Visit http://localhost:1337

That's it!

You're all set. You have a good foundation for building out your Sails.js application.