MERNjs is an open-source full-stack JavaScript solution, which provides a solid starting point for MongoDB, ExpressJS, ReactJS and NodeJS based applications. The idea is to solve the common issues with connecting those frameworks, build a robust framework to support daily development needs, and help developers use better practices while working with popular JavaScript components.
Before we begin, recommend to read about the basic building blocks that assemble a MERNjs application:
- MongoDB - Go through MongoDB Official Website and proceed to their Official Manual, which should help you understand NoSQL and MongoDB better.
- Express - The best way to understand express is through its Official Website, which has a Getting Started guide, as well as an ExpressJS guide for general express topics.
- ReactJS - React's Official Website is a great starting point.
- Node.js - Start by going through Node.js Official Website which should get you going with the Node.js platform in no time.
Make sure we have installed all of the following prerequisites on our development machine:
- Git - Download & Install Git. OSX and Linux machines typically have this already installed.
- Node.js - Download & Install Node.js and the npm package manager. If you encounter any problems, you can also use this GitHub Gist to install Node.js.
- MongoDB - Download & Install MongoDB, and make sure it's running on the default port (27017).
Currently there is a single way that we can get the MERNjs boilerplate:
The recommended way to get MERNjs is to use git to directly clone the MERNjs repository:
$ git clone https://github.com/IamMohaiminul/MERNjs MERNjs
This will clone the latest version of the MERNjs repository to a MERNjs folder.
To run our application follow this steps.
Note: Before start the process, rename .env.example
to .env
and configure the environment variables.
// both dependencies and devDependencies
$ npm install
// build both server and client
$ npm run build
// build only server
$ npm run build:server
// build only client
$ npm run build:client
// without debug mode
$ npm start
// with debug mode
$ npm run debug
// watch both server and client
$ npm run watch
// watch only server
$ npm run watch:server
// watch only client
$ npm run watch:client
Note: Please make sure our MongoDB is running.
Our application should run on port 3000
based on the environment configuration.
- Client App: http://127.0.0.1:3000
- Admin App: http://127.0.0.1:3000/admin
- RESTful APIs: http://127.0.0.1:3000/api