Use Yeoman to build AngularJS applications (1) Introduction-Mark_Li

Source: Internet
Author: User
Use Yeoman to build AngularJS application (1) -- Introduction-Mark_Li address: http://yeoman.io/learning/

Yeoman is a general base frame system that can create multiple applications. It helps users quickly create new projects and simplifies the maintenance process of existing projects.

Yeoman has no language restrictions. It can generate projects (Web, Java, Python, C #, and so on) written in any language ).

Yeoman does not make any decision on his own. Every decision is made by generators in the Yeoman environment. Here is a list of Generators /. Yeoman will provide the right choice based on the requirements of the Base Frame.

Here are some common examples:

  • Quickly create a new project
  • Create a new part of the project, such as a new unit test controller)
  • Create a module or package
  • Guide New Services
  • Enforced standards, best practices and Style Guidelines
  • Optimize new projects and allow users to create a simple application
  • And so on.
Getting started

Yo is a Yeoman command line utility that allows you to create a project (called a builder) using a base framework template. npm is used for installation of Yo and generators.

Install yo and some generators

The first thing is to use npm to install yo:

npm install -g yo

Then install the generator. The npm package naming rule of the generator is generator-XYZ. At http://yeoman.io/generators/you can configure the type of the generator. Then run the "install a generator" menu option using yo. Install the webapp builder:

npm install -g generator-webapp

New Node and npm users may experience permission issues. This issue will be displayed in the form of EACCESS errors during installation. If you have encountered this problem, please refer to https://docs.npmjs.com/getting-started/fixing-npm-permissions.

Npm is the manager of the Node. js package.

In Windows, we recommend that you use a better command line tool, such as cmder or PowerShell, to improve user experience.

Basic Base Frame

In the following example, we will use generator-webapp instead of webapp to name your generator.

Create a project with the base architecture and run:

yo webapp

Most generators will ask a series of questions from defining new projects. Run help to see which options can be set.

yo webapp --help

Most generators rely on build systems (such as Grunt or Gulp) and package managers (such as npm and Bower ). Visit the builder URL to learn about running and maintaining new applications. You can use commands to access the Web page of a generator.

npm home generator-webapp

The builder's base frame may provide additional generators to manage smaller parts of the project. These generators are often called sub-generators and are accessed using generator: sub-generator.

Use generator-angular as an example. Once this angular application has been generated, other features can also be added. You can use the following command to add a new controller.

yo angular:controller MyNewController

Other yo commands

In addition to the previous sections, yo is also a complete interactive tool. Simply input yo on the terminal will provide a list of options to manage related generators: Run, update, install, help and other utilities.

Yo also provides the following commands.

  • Get all secondary screens

yo --help

  • List installed generators

yo --generators

  • Get version

yo --version

Exception Handling

Run the following command to view the majority of problems

yo doctor

The doctor command will diagnose the problem and provide steps to solve the problem

The next chapter describes how to use Yeoman to create an AngularJS project.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.