Skip to content
Tutorials Center
My learning

Topics

Lesson 2 of 39 ยท Getting Started

Installing Ember and Project Structure

Install Node and Ember CLI, create your first app with ember new, start the dev server, and learn what every folder in an Ember project is for.

Everything in Ember starts from its command line tool, Ember CLI. It creates projects, generates files, runs the development server, builds for production and runs your tests. In this lesson you will install it, create an app, and tour the folders so that no file feels mysterious.

Real versus stand-in. Ember CLI needs Node.js and a file system, so it cannot run on this site. The terminal commands and the project tree below are real and read-only. The runnable blocks are small JavaScript stand-ins that show what the tools do conceptually, such as generating files from a name.

What you need first

  1. Node.js (an active LTS version) and its package manager. Check with node --version.
  2. Git is recommended, because ember new initializes a repository for you.
  3. A code editor. VS Code with an Ember extension gives you template highlighting and navigation.

You can use npm, pnpm or yarn. Ember's own guides default to npm and the generator picks it unless told otherwise.

Creating an app

You do not have to install Ember CLI globally. Run it with npx, which downloads the latest version just for this command:

Terminal
npx ember-cli@latest new super-rentals
cd super-rentals
npm start

The first command creates a folder named super-rentals and installs dependencies, which takes a minute. npm start runs the development server. Open http://localhost:4200 and you will see the welcome page. The page reloads automatically when you save a file (live reload).

Useful options for ember new:

Option Effect
--typescript Create a TypeScript project (.gts components).
--pnpm or --yarn Use another package manager.
--skip-git Do not create a Git repository.
--no-welcome Leave out the welcome page so you start with an empty screen.

Recent blueprints build with Vite through Embroider. Older projects use the classic build pipeline. The folder layout you work in is the same in both.

The project tree

TEXT
super-rentals/
  app/
    components/      reusable UI pieces
    controllers/     rarely needed state tied to a route
    models/          Ember Data record definitions
    routes/          one file per route: loads data, guards access
    services/        shared singletons
    templates/       one template per route
    app.js           application class and setup
    index.html       the single HTML page
    router.js        the URL map
    styles/app.css   global styles
  config/
    environment.js   settings per environment
  public/            files served as-is (images, robots.txt)
  tests/             unit, integration and acceptance tests
  package.json       dependencies and scripts

app/

This is where nearly all of your code lives. The subfolders are exactly the types of things Ember knows about. If you put a file in app/services/, it is a service; there is nothing to register.

app/router.js

The single place that lists your URLs. It is short and readable, so a new developer can understand the shape of the whole app by opening this one file. You will write it in Router Basics.

app/index.html

The only real HTML page. Ember apps are single-page applications: the browser loads this page once, and the router swaps screens in and out without a full reload.

config/environment.js

Holds settings such as the rootURL, API host, or feature flags, with different values for development, test and production. Your code reads it with import config from 'my-app/config/environment'.

public/

Anything here is copied untouched to the final build. Put images, fonts and robots.txt here and refer to them with a path starting at /.

tests/

Mirrors app/. Generators create the matching test file for you. The Testing chapter later in the track explains how the three kinds of test differ.

Everyday commands

Terminal
ember serve                 # dev server (also: npm start)
ember generate route about  # create route, template and test
ember generate component rental-card
ember test                  # run all tests once
ember test --server         # re-run tests on every change
ember build --environment=production

ember generate can be shortened to ember g. Generating is a convenience, not a requirement: you may create files by hand as long as you follow the naming conventions. The advantage of the generator is that it also wires up the test and avoids typos.

JS A tiny generator

Press Run (or Ctrl + Enter) to see the console output here.

No output.

How a request reaches your code

When you run npm start, the build tool compiles everything under app/ into a few JavaScript files plus your CSS and serves them with index.html. In the browser, app.js creates the application, the router reads the URL, and Ember looks for matching routes and templates using the folder conventions.

flowchart TD
  A["Browser opens index.html"] --> B["Loads compiled app JS and CSS"]
  B --> C["app.js boots the application"]
  C --> D["router.js reads the URL"]
  D --> E["Route file loads data"]
  E --> F["Template renders components"]

From the single HTML page to a rendered screen.

Dependencies and add-ons

Ember apps use normal npm packages, plus add-ons: packages that plug into the build, add components, or add generators. Install them with the add-on command so any setup steps run:

Terminal
ember install ember-modifier

Common examples are a CSS helper library, a mocking tool, or an accessibility test helper. The Build, Addons and Deployment chapter of this track covers them in depth.

JS Reading a project tree

Press Run (or Ctrl + Enter) to see the console output here.

No output.

Try adding your own questions; anything the table does not cover answers "unknown".

Common mistakes

  • Using the system's global ember command with an old version. Prefer npx ember-cli@latest new ... for new apps, and npm start or npx ember inside a project, so the project's own version is used.
  • Editing files in dist/. It is rebuilt on every build and is not source code.
  • Putting a file in the wrong folder. A component in app/routes/ is never found. Check the folder first when something "does nothing".
  • Ignoring warnings. Ember reports deprecations in the console with a link to a guide. Fix them as you go; upgrades are painless that way.

Check your understanding

Quick check ยท 4 questions

of 4 answered You scored / 4 ยท perfect!

  1. 1. Which command starts the development server in a new Ember project?

    npm start runs the project's start script, which runs ember serve. The server rebuilds and reloads when you change a file.
  2. 2. Where would you put a shared singleton such as a session service?

    Files in app/services are resolved as services and can be injected anywhere.
  3. 3. What is the purpose of the public/ folder?

    Public files are served as they are. The compiled build goes to dist/, and tests live in tests/.
  4. 4. Why is generating files with ember generate recommended?

    Generation is a convenience. Hand-written files work if they follow the naming conventions.

Summary

  • Install Node, then create an app with npx ember-cli@latest new my-app and run it with npm start.
  • Code lives in app/; each subfolder is a type Ember recognizes.
  • router.js is the URL map, index.html is the one HTML page, config/environment.js holds settings, public/ is copied as-is.
  • ember generate creates files and tests from a name, and add-ons are installed with ember install.

Next: Your First Ember Page