MongoDB is a free, cross-platform, open source, NoSQL document-oriented database. To install MongoDB on your Ubuntu system, refer the following guide:
To install NodeJS on your system, refer the following guide:
After installing, MongoDB, and Node.js, we need to install the other required components such as Yarn, Grunt, and Gulp for MEAN.js stack.
Install Yarn package manager
Yarn is a package manager used by MEAN.JS stack to manage front-end packages.
To install Bower, run the following command:
$ npm install -g yarn
Install Grunt Task Runner
Grunt Task Runner is used to to automate the development process.
To install Grunt, run:
$ npm install -g grunt-cli
To verify if Yarn and Grunt have been installed, run:
$ npm list -g --depth=0 /home/sk/.nvm/versions/node/v11.11.0/lib ├── email@example.com ├── firstname.lastname@example.org └── email@example.com
Install Gulp Task Runner (Optional)
This is optional. You can use Gulp instead of Grunt. To install Gulp Task Runner, run the following command:
$ npm install -g gulp
We have installed all required prerequisites. Now, let us deploy MEAN.JS stack.
Install MEAN.JS Stack
Install Git if it is not installed already:
$ sudo apt-get install git
Next, git clone the MEAN.JS repository with command:
$ git clone https://github.com/meanjs/mean.git meanjs
Cloning into 'meanjs'... remote: Counting objects: 8596, done. remote: Compressing objects: 100% (12/12), done. remote: Total 8596 (delta 3), reused 0 (delta 0), pack-reused 8584 Receiving objects: 100% (8596/8596), 2.62 MiB | 140.00 KiB/s, done. Resolving deltas: 100% (4322/4322), done. Checking connectivity... done.
The above command will clone the latest version of the MEAN.JS repository to meanjs folder in your current working directory.
Go to the meanjs folder:
$ cd meanjs/
Run the following command to install the Node.js dependencies required for testing and running our application:
$ npm install
This will take some time. Please be patient.
When I run the above command in Ubuntu 18.04 LTS, I get the following error:
Downloading binary from https://github.com/sass/node-sass/releases/download/v4.5.3/linux-x64-67_binding.node Cannot download "https://github.com/sass/node-sass/releases/download/v4.5.3/linux-x64-67_binding.node": HTTP error 404 Not Found [....]
If you ever get these type of common errors like "node-sass and gulp-sass", do the following:
First uninstall the project and global gulp-sass modules using the following commands:
$ npm uninstall gulp-sass $ npm uninstall -g gulp-sass
Next uninstall the global node-sass module:
$ npm uninstall -g node-sass
Install the global node-sass first. Then install the gulp-sass module at the local project level.
$ npm install -g node-sass $ npm install gulp-sass
Now try the npm install again from the project folder using command:
$ npm install
Now all dependencies will start to install without any issues.
Once all dependencies are installed, run the following command to install all the front-end modules needed for the application:
$ yarn --allow-root --config.interactive=false install
$ yarn --allow-root install
You will see the following message at the end if the installation is successful.
[...] > firstname.lastname@example.org snyk-protect /home/sk/meanjs > snyk protect Successfully applied Snyk patches Done in 99.47s.
MEAN.JS stack has been installed. We can now able to start a sample application using command:
$ npm start
After a few seconds, you will see a message like below. This means MEAN.JS stack is working!
[...] MEAN.JS - Development Environment Environment: development Server: http://0.0.0.0:3000 Database: mongodb://localhost/mean-dev App version: 0.6.0 MEAN.JS version: 0.6.0
To verify, open up the browser and navigate to http://localhost:3000 or http://IP-Address:3000/. You should see a screen something like below.
Congratulations! MEAN.JS stack is ready to start building web applications.
For further details, I recommend you to refer MEAN.JS stack official documentation.
Want to setup MEAN.JS stack in CentOS, RHEL, Scientific Linux? Check the following link for more details.
And, that's all for now, folks. Hope this tutorial will help you to setup MEAN.JS stack.