MEAN StackMEAN is a framework for an easy starting point with MongoDB, Node.js, Express, and AngularJS based applications. It is designed to give you a quick and organized way to start developing MEAN based web apps with useful modules like Mongoose and Passport pre-bundled and configured. We mainly try to take care of the connection points between existing popular frameworks and solve common integration problems.
If you're using ubuntu, this is the preferred repository to use...
$ curl -sL https://deb.nodesource.com/setup_4.x | sudo -E bash -
$ sudo apt-get update
$ sudo apt-get install nodejs
$ npm install -g gulp
// and bower
$ npm install -g bower
To start with MEAN install the mean-cli package from NPM.
This will add the mean command which lets you interact (install, manage, update ...) your Mean based application.
In linux install in globally as root
$ sudo npm install -g mean-cli
$ mean init <myApp>
$ cd <myApp> && npm install
Mean supports the gulp task runner for various services which are applied on the code. To start your application run -
$ gulp
Alternatively, when not using gulp (and for production environments) you can run:
$ node server
Then, open a browser and go to:
http://localhost:3000
If you have a rails, node, or other mean project already running, you may need to use a different port. You can set the port and start your new mean project with one command:
$ export PORT=3001 && gulp
Then, open a browser and change the port number before you visit:
http://localhost:3001
During installation depending on your os and prerequisite versions you may encounter some issues.
Most issues can be solved by one of the following tips, but if you are unable to find a solution feel free to contact us via the repository issue tracker or the links provided below.
Sometimes you may find there is a weird error during install like npm's Error: ENOENT. Usually updating those tools to the latest version solves the issue.
$ npm update -g npm
$ npm update -g gulp
$ npm update -g bower
NPM and Bower has a caching system for holding packages that you already installed. We found that often cleaning the cache solves some troubles this system creates.
$ npm cache clean
$ bower cache clean
Some of Mean.io dependencies uses node-gyp with supported Python version 2.7.x. So if you see an error related to node-gyp rebuild follow next steps:
$ npm update -g
If you get this error when trying to mean init:
Prerequisite not installed: git
And you definitely have Git for Windows installed, then it's not included in your path. Find the folder containing git.exe (likely C:\Program Files (x86)\Git\cmd) and add it to your PATH.
MEAN is an acronym for Mongo, Express.js , Angular.js and Node.js
The MEAN CLI is a simple Command Line Interface for installing and managing MEAN applications. As a core module of the Mean.io project, it provides a number of useful tools to make interaction with your MEAN application easier, with features such as: scaffolding, module creation and admin, status checks, and user management.
$ mean
$ mean --help
$ mean help
mean help can also be used in conjunction with any command to get more information about that particular functionality. For example, try mean help init to see the options for init
$ mean help [command]
Information can be display for a specific customer via mean user email. Email is required. User roles can be assigned or removed with the --addRole (or -a) and --removeRole (or -r) options, respectively.
For example, the admin role is required to edit tokens.
$ mean user <email>
$ mean user <email> --addRole <role>;
$ mean user <email> --removeRole <role>;
All of the remaining of the commands must be run from the root folder of your MEAN application.
Contributed MEAN packages can be installed or uninstalled via the CLI. Also, currently installed modules can be viewed with the list command.
$ mean list
$ mean install <module>
$ mean uninstall <module>
Mean packages installed via the installer are found in /node_modules
To find new packages run the mean search command
$ mean search [packagename]
mean search will return all of the available packages, mean search [packagename] will filter the search results.
To create a new MEAN app, run mean init. Name for the application is optional. If no name is provided, "mean" is used. The MEAN project will be cloned from GitHub into a directory of the application name.
$ mean init [name]
$ cd [name] && npm install
Note: git must be installed for this command to work properly.
Check the database connection for a particular environment (e.g. development (default), test, production) and make sure that the meanio command line version is up to date.
$ mean status
A simple shortcut to open the mean documentation in your default browser.
$ mean docs
Everything in mean.io is a package and when extending mean with custom functionality make sure you create your own package and do not alter the core packages.
The mean.io package system allows developers to create modular code that provides useful tools that other mean developers can use. The packages, when published, are plug-and-play and are used in a way very similar to traditional npm packages.
The mean.io package system integrates all the packages into the mean project as if the code was part of mean itself and provides the developers with all the necessary tools required to integrate their package into the host project.
There are two types of packages:
Custom Packages are generated by the mean scaffolder and contain most of your application logic. Custom packages are found in /packages/custom and can be published as a contrib package for use by other developers.
Contrib Packages are installed by the mean installer and are found at /packages/contrib. Contrib packages are "plug and play".
All Core packages can be overridden by other packages allowing you to extend and adapt it to fit your specific needs. See Overriding views for detailed examples.
The "system" package creates the basic pages as well as defines the layout of the site and integrates the menu into the page. The system package also allows us to define things such as rendering engines, static files and routing on the client and server side.
The "users" package creates the database model of the user, provides validation as well as various login and registration features.
The "access" package manages permissions and middleware. It controls the various authentication methods and is dependent on the users package
The "theme" package adds some basic CSS and other assets such as images and backgrounds
The "articles" package is typically used as an example starting point for managing content that might be used in a blog or cms. The full CRUD is implemented on the server and client.
The file structure is similar to that of the mean project itself
Fundamental Files at the root of the package
Server
Packages are registered in the app.js
Defines package name, version and mean=true in the package.json
All of the Server side code resides in the /server directory.
Server
--- config # Configuration files
--- controllers # Server side logic goes here
--- models # Database Schema Models
--- routes # Rest api endpoints for routing
--- views # Swig based html rendering
Client
All of the Client side code resides in the /public directory.
public
--- assets # JavaScript/CSS/Images (not aggregated)
--- controllers # Angular controllers
--- config # Contains routing files
--- services # Angular services (also directive and filter folders)
--- views # Angular views
All JavaScript within public is automatically aggregated with the exception of files in public/assets, which can be manually added using the aggregateAsset() function.
Files within the public directory of the package can be accessed externally at /[package-name]/path-to-file-relative-to-public. For example, to access the Tokens Angular controller, tokens/controllers/tokens.js.
In order for a Package to work it needs to be registered. By doing this you make the package system aware that you are ready and that other packages are able to depend on you. The packages are