Angular-cli_angular-cl

Source: Internet
Author: User
1 installation and use first ensure that the Nodejs is installed. NPM i angular-cli-g. The Global keyword for ng-cli is ng. Create a new project: Ng new ProjectName [options]. Create component: Ng G component componentname. Start Server:ng serve, default port 4200. Packaging: ng build--prod, the default generation/dist directory, and the packaged results are stored here. Test: NG test, run unit tests using Karma. CLI version: NG version error detection: NG Lint, running Codelyzer linter detection. 2 Command Reference 2.1 Create project
Command: ng new Proname [options]
Parameter description –dry-run-d outputs only the files to be created and the actions performed, and the project –VERBOSE-V output details are not actually created –SKIP-NPM do not perform any NPM commands when the project is first created –name specify the name of the creation Project 2.2 initialization project

Initializes a new angular project in the current directory
Command: NG init proname [Options]
parameter to create the project. 2.3 Creating classes

Create code for modules, components, directives, and so on in your project.

Command: ng generate <type> [options]
shorthand: ng g <type> [Options]
Type usage Component ng g Component my-new-component Directive ng G Directive my-new-directive Pipe ng G Pipe my-new-pipe Servi Ce ng G service my-new-service class Ng G class My-new-class Interface ng g Interface my-new-interface enum ng g enum my-n Ew-enum module ng g module my-module Route ng G Route My-route is currently disabled

Parameters: Parameter Description –flat does not create code within its own directory –route=<route> specifies the parent route. For build components and routes only. The default is the specified path. –skip-router-generation Bypass generation Parent routing configuration. Can only be used for routing commands. –DEFAULT specifies that the route should be the default route. –LAZY Specifies that the route is deferred. The default is true. 2.4 Get/Set CLI configuration

Get configuration:

Command: ng get <path1, path2, ...pathn> [options]

To set the configuration:

Command: ng get <path1=value1, Path2=value2, ...pathn=valuen> [options]

Options: Parameter Description –global Returns the global configuration value, not the local configuration value (if all is set). This option also enables the command to work outside the project directory 2.5 test

Run unit tests using Karma
Command: NG test [options] parameter description –watch continue to run the test. Defaults to True–browsers, –colors, –reporters, –port, –log-level These parameters are passed directly to Karma 3 create components in the app folder by default under the SRC directory where components are created in the specified directory. If you want to create in a subdirectory, you need to go to this directory first and then execute NG G. 4 using Sass

It is convenient to use SASS in the NG2 project created by the CLI, simply by changing the CSS suffix of your style file to scss and referencing it in Component.ts, where Sass-loader is already configured within the CLI.

There is one configuration in the Angular-cli.json in the project:

  "Defaults": {
    "styleext": "CSS"
  }

This looks like it should be changed to SCSS, but I did not change, packaging, startup server is no problem. 5 Installation ANGULAR-CLI Error

Today, download the Nicefish project in the desert, then start npm I, install ANGULAR-CLI when the error, found that this project and my global NG-CLI version inconsistent, and then NPM tips

NPM WARN deprecated angular-cli@1.0.0-beta.28.3:angular-cli has been rename

And then it just jammed. I can see the meaning of this sentence, but I don't know how to solve it. Because my ng-cli is no longer available.
Then I started tossing and dropping all the NG-CLI packages, using everything to retrieve the angular of all directories, in addition to the angular-cli that appear in the project, generally appears in the following several directories:
1. c:user/chengyanzhao/appdata/local&roaming
2. NPM Global Package path

I removed the ng-cli content from these positions, but it didn't work, and then uninstalled the Nodejs, and the reinstall was still invalid.

Later, a variety of search data, found that NPM in the installation of the package can see progress

NPM I angular-cli-g--verbose

And then see where the inside installed when the error occurred. such as Gyp, Node-sass and so on. The problem of the global installation, and then installed NG-CLI.

Finally the installation succeeded ..... Heart plug.

Here's a note, in case you don't know how to fix it later.

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.