官术网_书友最值得收藏!

Initializing Angular app

Now, we will initialize the application for development using npx, which is already installed on your system when you installed the latest version of Node LTS:

  1. Under your dev folder, execute npx @angular/cli new local-weather-app
  2. On your terminal, you should see a success message similar to this:
...  
create local-weather-app/src/tsconfig.app.json (211 bytes)
create local-weather-app/src/tsconfig.spec.json (283 bytes)
create local-weather-app/src/typings.d.ts (104 bytes)
create local-weather-app/src/app/app.module.ts (316 bytes)
create local-weather-app/src/app/app.component.html (1141 bytes)
create local-weather-app/src/app/app.component.spec.ts (986 bytes)
create local-weather-app/src/app/app.component.ts (207 bytes)
create local-weather-app/src/app/app.component.css (0 bytes)
added 1273 packages from 1238 contributors in 60.594s
Project 'local-weather-app' successfully created.

Your project folder—local-weather-app—has been initialized as a Git repository and scaffolded with the initial file and folder structure, which should look like this:

local-weather-app
├── angular.json
├── .editorconfig
├── .gitignore
├── .gitkeep
├── e2e
├── karma.conf.js
├── node_modules
├── package-lock.json
├── package.json
├── protractor.conf.js
├── README.md
├── src
├── tsconfig.json
└── tslint.json

The alias for @angular/cli is ngIf you were to install Angular CLI globally, you would have simply executed ng new local-weather-app, but we didn't do this. So it is important to remember that going forward, you will be executing the ng command, but this time under the local-weather-app directory. The latest version of Angular CLI has been installed under the node_modules/.bin directory, so you can run ng commands such as npx ng generate component my-new-component and continue working in an effective manner.

If you are on macOS, you can further improve your development experience by implementing shell auto fallback, which removes the necessity of having to use the npx command. If an unknown command is found, npx will take over the request. If the package already locally exists under node_modules/.bin, the npx will pass along your request to the correct binary. So, you will just be able to run commands like ng g c my-new-component as if they're globally installed. Refer to npx's readme on how to set this up at npmjs.com/package/npx#shell-auto-fallback.

主站蜘蛛池模板: 伊金霍洛旗| 铁岭县| 朝阳区| 唐海县| 蓬溪县| 隆昌县| 富阳市| 洛宁县| 牟定县| 堆龙德庆县| 永修县| 新安县| 汤阴县| 新巴尔虎左旗| 青海省| 淳化县| 漳州市| 兰溪市| 黑河市| 元阳县| 顺昌县| 宜良县| 广平县| 丁青县| 宝山区| 安平县| 游戏| 石台县| 报价| 铜鼓县| 夏邑县| 奉节县| 陕西省| 明光市| 乳源| 伽师县| 老河口市| 定远县| 濉溪县| 六枝特区| 沽源县|