Skip to main content

MEAN Stack Development with Vagrant

MEAN Stack Development with Vagrant

  • Introduction
    • Vagrant provides easy to configure, reproducible, and portable work environments built on top of industry-standard technology and controlled by a single consistent workflow to help maximize the productivity and flexibility of you and your team.
    • To achieve its magic, Vagrant stands on the shoulders of giants. Machines are provisioned on top of VirtualBox, VMware, AWS, or any other provider. Then, industry-standard provisioning tools such as shell scripts, Chef, or Puppet, can be used to automatically install and configure software on the machine.

  1. Setup Virtualbox

          You have to completely remove older VirtualBox versions before
              installing VirtualBox-5.0 !

    1. Display Allready Installed Packages
      1. sudo dpkg -l | grep virtualbox
    2. Uninstall VirtualBox
      1. sudo apt-get purge "^virtualbox-.*"
    3. Update the software repositories

      1. sudo apt-get update
    4. Clean up
      1. sudo apt-get autoremove | sudo apt-get autoclean | sudo apt-get clean
    5. Setup API repository (For Ubuntu 14.04 ("Trusty"))
      1. echo "deb http://download.virtualbox.org/virtualbox/debian trusty contrib" | sudo tee /etc/apt/sources.list.d/oracle-vbox.list
    6. Setup Oracle Key
      1. wget -q https://www.virtualbox.org/download/oracle_vbox_2016.asc -O- | sudo apt-key add -
      2. wget -q https://www.virtualbox.org/download/oracle_vbox.asc -O- | sudo apt-key add -
    7. Install Oracle Virtualbox
      1. sudo apt-get update
      2. sudo apt-get install virtualbox-5.1
    8. Start Virtualbox
      1. virtualbox

  1. Vagrant Setup

    1. Once the above step is done, we will download Vagrant. You can head to their download page and download an appropriate version for your OS.
    2. Common Vagrant command are as follows
      1. vagrant box list #List all Vagrant boxes installed on your machine
      2. vagrant init xxx #Adds a new Vagrant box with the name xxx
      3. vagrant up #Boots the Vagrant box
      4. vagrant ssh #Connect to the Vagrant box via SSH
      5. vagrant reload #If you have updated the Vagrantfile, you need to reload the VM to reflect the changes. This commands does precisely that.
      6. vagrant halt   #Stops the Vagrant box
      7. vagrant destroy #Remove the Vagrant instance from your machine (All data in the VM will be lost)

  1. Create a custom MEAN Stack Vagrant box


    1. The first step in configuring any Vagrant project is to create a Vagrantfile. The purpose of the Vagrantfile is :
      1. Mark the root directory of your project. Many of the configuration options in Vagrant are relative to this root directory.
      2. Describe the kind of machine and resources you need to run your project, as well as what software to install and how you want to access it.
    2. Up and Running

      1. Vagrant up && vagrant ssh

    1. We are inside the VM now. Next, we will install the components needed for MEAN stack development.

      1. Git
        1. sudo apt-get install git
        2. git --version

      1. Node.js
        1. sudo apt-get update
        2. sudo apt-get install -y python-software-properties python g++ make
        3. sudo add-apt-repository ppa:chris-lea/node.js
        4. sudo apt-get update
        5. sudo apt-get install nodejs
        6. node -v
        7. npm -v

      1. MongoDB
        1. sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 7F0CEB10
        2. echo 'deb http://downloads-distro.mongodb.org/repo/ubuntu-upstart dist 10gen' | sudo tee /etc/apt/sources.list.d/mongodb.list
        3. sudo apt-get update
        4. sudo apt-get install -y mongodb-org
        5. mongo --version

      1. Install Node.js tools
        1. sudo npm install -g bower grunt-cli yo generator-meanjs

  1. Issues on vagrant up

      1. Solution : This issue get solved by executing above steps sequentially.
    1. Fixing Error "Failed to load VMMR0.r0 (VERR_SUPLIB_WORLD_WRITABLE)" in Virtualbox
      1. Solution : chmod o-w /usr/lib

  1. References
    1. VBoxManage: error: Details: code NS_ERROR_FAILURE

    2. How to Install Oracle VirtualBox 5.1 on Ubuntu 16.04 & 15.10 and Debian 8/7


Comments

  1. Hi Santosh , I am facing the similar error but on Mac OSX yosemite. Tried uninstalling and reinstalling but to no help. Can you please suggest something?

    This is the error I am getting:
    There was an error while executing `VBoxManage`, a CLI used by Vagrant
    for controlling VirtualBox. The command and stderr is shown below.

    Command: ["startvm", "51266d9c-9c5a-402f-9cf7-dcf3a159b791", "--type", "headless"]

    Stderr: VBoxManage: error: The virtual machine 'vagrant_default_1494573999092_37112' has terminated unexpectedly during startup with exit code 1 (0x1)
    VBoxManage: error: Details: code NS_ERROR_FAILURE (0x80004005), component MachineWrap, interface IMachine

    ReplyDelete

Post a Comment

Popular posts from this blog

Create A File Chooser Using Ionic Framework

The following Content will show you how to create file chooser in  your Android application using Ionic Framework.There are number of plugins available to implement this tutorial. To implement this , we’ll be using the plugin com.maginsoft.mfilechooser 1.0.0.
1.Create the project
ionic start Test blank cd Test ionic platform add android
2.Add Plugin Cordova/Phonegap plugin that supplies a File Chooser for Android 4+. The File Chooser does not require installation external file manager.This plugin not supported in browser for testing build in device. To install the plugin
cordova plugin add https://github.com/MaginSoft/MFileChooser.git How to use Plugin Thisplugin documentation available on https://github.com/MaginSoft/MFileChooser  and I am so thankful to Abakhov Sergey for the implementation of its plugin and help to us. The plugin creates the object window.plugins.mfilechooser. To use, call the open() method:

File Upload & Download With ng-cordova File Transfer Plugin In Ionic Framework

Using the AngularJS extension set,ngCordova, with Ionic Framework and the Apache CordovaFile Transfer plugin, you can easily upload files to a remote server and download files from a remote server.

1.Create the project

ionic start Test blank cd Test ionic platform add android

2.Add Plugin org.apache.cordova.file-transfer https://github.com/apache/cordova-plugin-file-transfer This plugin allows you to upload and download files. This plugin defines global FileTransfer, FileUploadOptions Constructors. Although in the global scope, they are not available until after the deviceready event. Installation cordova plugin add cordova plugin add cordova-plugin-file-transfer

    2.   org.apache.cordova.file https://github.com/apache/cordova-plugin-file

Steps To Create Cordova Plugin

Introduction
A plugin is a package of injected code that allows the Cordova webview within which the app renders to communicate with the native platform on which it runs. Plugins comprise a single JavaScript interface along with corresponding native code libraries for each supported platform. Due to following reason, we will go for plugin development To get the native capabilities of the device in the cordova based app Build the common functionality across the number of Cordova application(Reusability)












Prerequisites
For the creation of plugin you need to install plugman. npm install -g plugman
Plugin Structure
Decide Plugin ID & Name The plugin ID should be unique