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

What exactly means MVW design pattern ?

What is a MVW framework? The abbreviation stands for 'Model - View - Whatever'.  Well there are many different JavaScript frameworks available , all invented for the same purpose. They all try to separate the presentation logic from the business logic where JavaScript holds the model and logic, and html the presentation layer. Quick overview : You can change the model without changing the view and vice-versa Unit testing is easy These are the core benefits of using such a framework. By separating presentation and business logic changes to the code are easier to implement and take less time. Another benefit is that code can be reused from a controller thus saving more time. Angularjs makes the code also shorter in comparison to other frameworks, which improves code stability. Less code means minor potential for bugs. For several years +AngularJS was closer to MVC (or rather one of its client-side variants), but over time and thanks to many refactorings...

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

Using the AngularJS extension set , ngCordova , with Ionic Framework and the Apache Cordova File 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             This plugin implements a Fi...

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 Plugin name should follow the convention “cordova.plugin.[your.plugin.name]” Create the structure Use the following command to create the plugin with plugin ID “cordova.plugin.test” and name “Test”. plugman create --name Test --...