Get started with Magpie

Before we start

This tutorial assumes you have the following things installed and configured on your machine:

  • Nodejs (version greater than 8)
  • Mongodb
  • NPM
  • Angular cli
  • Git


To install Magpie on your local machine,follow below steps:

Step 1 - Install package from npm

Use the following command to install framework

 npm i -g magpie_cli

Note: If you are using a linux system set the Environment Variable path before installing the framework

To set Environment Variable path open Home > .profile by using following command

 sudo gedit ~/.profile

After opening replace the PATH="$HOME/bin:$HOME/.local/bin:$PATH" by following path. After this try again to install


If you find any difficulty in installing remove the npm cache using following command and try again

 sudo npm cache clear -f

Run the following command in a terminal to verify the installation

mag v

Step 2 - Create new project

Navigate to the folder where you want create a new project and use following command to create a new project

mag create testproject

This will create a new project named testproject

Step 3 - Connect Mongodb

Open config > DB.js. Replace the following code with your credentials

              module.exports = {
                secret:'YOUR SECRET KEY HERE',
                DB: 'YOUR MONGODB PATH/DB NAME'

Here is a sample DB configuration which is used in this tutorial

                module.exports = {
                  DB: 'mongodb://localhost:27017/magpie'

Step 5 - Build the application

Open terminal and Start mongodb service

sudo service mongod start

Open the project folder in a terminal and run

nodemon server.js

Open the project folder in another terminal and run

ng serve

If everything was set up correctly you will get the following screen if you go to http://localhost:4200/

Now that everything is set up correctly, lets dive in to a CRUD Simple CRUD Tutorial