Setting up ember-cli development environment with ember 2.1
Create a frontend web applications that use Django and other backend solutions as it data source.
In a series of tutorials starting with this one I'll try to showcase ember.js framework for building fronted web applications. As a backend there will be Django Rest Frameowork and more.
My tutorials will be based or will extend the offical guide as well as excellent guide on learnhowtoprogram.com.
Installing ember-cli under Linux
As most tutorials cover OS X (or Windows) I'll go with Linux. The difference is in brew tool which has different ports for every OS. Aside of that it should be similar.
We can start with downloading nvm - a node.js version manager, that makes it easier to manage node.js installations on your computer (something like an virtualenv). Do download run:
Then you can install a selected version of node (locally in home directory):
At any moment we can start using given node version:
Now we can globally install ember-cli for used node version:
Optional dependency is watchman, a code observer/brower reloader (checks for changes in code and reloads the browser tab with opened application page). For OS X we can use homebrew, but for Linux we have to use linuxbrew:
Brewmaster will be available as ~/.linuxbrew/bin/brew and to make it available in your terminal add it to .bashrc:
When we have brewmaster we can install watchman:
When the install finishes we will get a notice:
Do what it asks you to do. Then we can start with creating application structure for your new ember.js project:
The development server will run on http://localhost:4200/
ember-cli within Docker
If you want to separate node and ember-cli from your system you can use a Docker image with all the tools installed. Docker itself can be installed from your distribution repository or from get.docker.com (bash script, download it and execute it) where you will find the latest version (recommended).
After installing Docker add yourself to docker group so you won't have to use sudo/root to use Docker.
There are few ember-cli Docker images made available by the community. One of them is danlynn/ember-cli. To use it we will have to also install docker-componse which is a tool for making docker commands shorter and easier to perform or automate:
When using this Docker image create an empty directory and in it create a docker-compose.yml file:
And then we can use ember-cli embedded inside that Docker image to create a new ember application:
Docker image will run the server on port 4200, but to get to it we have to know the IP under which that Docker image is available on your computer. To check it list containers with docker ps (should be one we just started) and then run docker inspect CONTAINER_ID which will list a bunch of data. Look for IPAddress key under which you will get the local IP address under which the development server is available.
Updating to latest ember.js release
At the time of writing this tutorial ember-cli installs ember 1.3, while latest version is 2.1. To update your project edit bower.json and bump package versions:
then run bower install. Next edit package.json and bump versions:
And run npm install. That's it, you now have the latest ember.js up and running.